diff --git a/src/Translator/TranslatorContainer.cpp b/src/Translator/TranslatorContainer.cpp index 82a6320f..7e3c44bb 100644 --- a/src/Translator/TranslatorContainer.cpp +++ b/src/Translator/TranslatorContainer.cpp @@ -30,10 +30,12 @@ TranslatorContainer::TranslatorContainer(QApplication & /* app */) if ((localeDefault.name().toLower() != "en_us") || (localeDefault.name().toLower() != locale.name().toLower())) { + QString localeName = locale.name().toLower(); + // Basic translators, like buttons in QWizard m_translatorGeneric = new QTranslator; - m_translatorGeneric->load ("qt_" + locale.name().toLower(), - QLibraryInfo::location (QLibraryInfo::TranslationsPath)); + m_translatorGeneric->load ("qt_" + localeName, + QLibraryInfo::location (QLibraryInfo::TranslationsPath)); QApplication::installTranslator (m_translatorGeneric); // Engauge-specific translators. As documented in engauge.pro, the country-specific engauge_XX_YY locale is loaded @@ -43,9 +45,19 @@ TranslatorContainer::TranslatorContainer(QApplication & /* app */) // QCoreApplication::applicationDirPath points to ../Engauge Digitizer.app/Contents/MacOS (which we want) QString delimiters ("._"); m_translatorEngauge = new QTranslator; - m_translatorEngauge->load ("engauge_" + locale.name().toLower(), - qmDirectory(), - delimiters); + // Handle usual translations like es_es + bool rtn = m_translatorEngauge->load ("engauge_" + localeName, + qmDirectory(), + delimiters); + if (!rtn) { + // Handle country-specific translations like fa_IR. Transifex capitalizes the last two characters + QString localeNameUpper = QString ("%1%2") + .arg (localeName.left (localeName.length() - 2)) + .arg (localeName.right (2).toUpper ()); + m_translatorEngauge->load ("engauge_" + localeNameUpper, + qmDirectory(), + delimiters); + } QApplication::installTranslator (m_translatorEngauge); } }