From ad063b06348a0b2206793ea908afe8b732604679 Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Sun, 24 Feb 2013 15:22:21 +0100 Subject: [PATCH] Make chinese translations work on OS X ... by mapping chinese script codes to country codes as used by Qt and Transifex. --- src/mirall/application.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/mirall/application.cpp b/src/mirall/application.cpp index cc162f6a60..c4dcde9c73 100644 --- a/src/mirall/application.cpp +++ b/src/mirall/application.cpp @@ -1008,6 +1008,21 @@ void Application::setHelp() _helpOnly = true; } +QString substLang(const QString &lang) +{ + // Map the more apropriate script codes + // to country codes as used by Qt and + // transifex translation conventions. + + // Simplified Chinese + if (lang == QLatin1String("zh_Hans")) + return QLatin1String("zh_CN"); + // Traditional Chinese + if (lang == QLatin1String("zh_Hant")) + return QLatin1String("zh_TW"); + return lang; +} + void Application::setupTranslations() { QStringList uiLanguages; @@ -1029,6 +1044,7 @@ void Application::setupTranslations() foreach(QString lang, uiLanguages) { lang.replace(QLatin1Char('-'), QLatin1Char('_')); // work around QTBUG-25973 + lang = substLang(lang); const QString trPath = applicationTrPath(); const QString trFile = QLatin1String("mirall_") + lang; if (translator->load(trFile, trPath) ||