#include <QtTest/QtTest>
#include "../../src/core/translator.h"

class TestTranslator : public QObject
{
    Q_OBJECT
private slots:
    void initTestCase();
    void testLoadLanguage();
    void testTranslation();
    void testCleanup();
};

void TestTranslator::initTestCase()
{
    // Ensure we start with a clean state (singleton may persist)
    // Since Translator is a singleton, we can reload language.
    Translator& translator = Translator::instance();
    translator.loadLanguage("en_US");
}

void TestTranslator::testLoadLanguage()
{
    Translator& translator = Translator::instance();
    QVERIFY(translator.loadLanguage("en_US"));
    QCOMPARE(translator.currentLanguage(), QString("en_US"));
}

void TestTranslator::testTranslation()
{
    Translator& translator = Translator::instance();
    // Test known keys
    QCOMPARE(translator.tr("appName"), QString("Wino Mail"));
    QCOMPARE(translator.tr("welcomeMessage"), QString("Welcome to Wino Mail"));
    QCOMPARE(translator.tr("inbox"), QString("Inbox"));
    QCOMPARE(translator.tr("settings"), QString("Settings"));
    // Test unknown key returns the key itself
    QCOMPARE(translator.tr("unknown.key"), QString("unknown.key"));
}

void TestTranslator::testCleanup()
{
    // Nothing to clean up
}

QTEST_MAIN(TestTranslator)
#include "test_translator.moc"
