Skip to content

Commit

Permalink
Farsi support for #350
Browse files Browse the repository at this point in the history
  • Loading branch information
markummitchell-tu committed Aug 17, 2019
1 parent 04de130 commit b3f5924
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/Translator/TranslatorContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
}
Expand Down

0 comments on commit b3f5924

Please sign in to comment.