From fb7ba92f69c93dc0a965d10ad0d2d88c620929ac Mon Sep 17 00:00:00 2001 From: sledgehammer999 Date: Mon, 15 Jun 2015 00:13:52 +0300 Subject: [PATCH] Rename Chinese translation files. Closes #2936. --- src/app/application.cpp | 14 +++++++++++++- src/gui/options_imp.cpp | 16 ++++++++++++++-- src/lang.qrc | 4 ++-- ...{qbittorrent_zh.ts => qbittorrent_zh_Hans.ts} | 2 +- ...ittorrent_zh_TW.ts => qbittorrent_zh_Hant.ts} | 2 +- src/src.pro | 4 ++-- src/webui/www/public/preferences_content.html | 4 ++-- 7 files changed, 35 insertions(+), 11 deletions(-) rename src/lang/{qbittorrent_zh.ts => qbittorrent_zh_Hans.ts} (99%) rename src/lang/{qbittorrent_zh_TW.ts => qbittorrent_zh_Hant.ts} (99%) diff --git a/src/app/application.cpp b/src/app/application.cpp index 9ffd1104d..cfdfe7c36 100644 --- a/src/app/application.cpp +++ b/src/app/application.cpp @@ -337,8 +337,20 @@ void Application::initializeTranslation() Preferences* const pref = Preferences::instance(); // Load translation QString locale = pref->getLocale(); + if (locale.isEmpty()) { - locale = QLocale::system().name(); + QLocale systemLocale = QLocale::system(); + // Check if Chinese and act according to script instead of country + if (systemLocale.language() == QLocale::Chinese) { + if (systemLocale.script() == QLocale::SimplifiedHanScript) + locale = "zh_Hans"; + else + locale = "zh_Hant"; + } + else { + locale = systemLocale.name(); + } + pref->setLocale(locale); } diff --git a/src/gui/options_imp.cpp b/src/gui/options_imp.cpp index 461e082e5..00587ecf5 100644 --- a/src/gui/options_imp.cpp +++ b/src/gui/options_imp.cpp @@ -1075,7 +1075,19 @@ QString options_imp::getLocale() const { void options_imp::setLocale(const QString &localeStr) { QLocale locale(localeStr); - QString name = locale.name(); + QString name; + + // Check if Chinese and act according to script instead of country + if (locale.language() == QLocale::Chinese) { + if (locale.script() == QLocale::SimplifiedHanScript) + name = "zh_Hans"; + else + name = "zh_Hant"; + } + else { + name = locale.name(); + } + // Attempt to find exact match int index = comboI18n->findData(name, Qt::UserRole); if (index < 0 ) { @@ -1360,7 +1372,7 @@ QString options_imp::languageToLocalizedString(const QLocale &locale) case QLocale::Basque: return QString::fromUtf8("Euskara"); case QLocale::Vietnamese: return QString::fromUtf8("tiếng Việt"); case QLocale::Chinese: { - if (locale.country() == QLocale::China) + if (locale.script() == QLocale::SimplifiedHanScript) return QString::fromUtf8("中文 (简体)"); return QString::fromUtf8("中文 (繁體)"); } diff --git a/src/lang.qrc b/src/lang.qrc index 143d0f9d7..ff9ef69d5 100644 --- a/src/lang.qrc +++ b/src/lang.qrc @@ -40,7 +40,7 @@ lang/qbittorrent_tr.qm lang/qbittorrent_uk.qm lang/qbittorrent_vi.qm - lang/qbittorrent_zh.qm - lang/qbittorrent_zh_TW.qm + lang/qbittorrent_zh_Hans.qm + lang/qbittorrent_zh_Hant.qm diff --git a/src/lang/qbittorrent_zh.ts b/src/lang/qbittorrent_zh_Hans.ts similarity index 99% rename from src/lang/qbittorrent_zh.ts rename to src/lang/qbittorrent_zh_Hans.ts index ba09768d1..a29c10120 100644 --- a/src/lang/qbittorrent_zh.ts +++ b/src/lang/qbittorrent_zh_Hans.ts @@ -1,6 +1,6 @@ - + AboutDlg diff --git a/src/lang/qbittorrent_zh_TW.ts b/src/lang/qbittorrent_zh_Hant.ts similarity index 99% rename from src/lang/qbittorrent_zh_TW.ts rename to src/lang/qbittorrent_zh_Hant.ts index 6647b5fb5..2c29c47b2 100644 --- a/src/lang/qbittorrent_zh_TW.ts +++ b/src/lang/qbittorrent_zh_Hant.ts @@ -1,6 +1,6 @@ - + AboutDlg diff --git a/src/src.pro b/src/src.pro index c194557f2..142927066 100644 --- a/src/src.pro +++ b/src/src.pro @@ -75,8 +75,8 @@ RESOURCES += \ # Translations TRANSLATIONS = \ $$LANG_PATH/qbittorrent_fr.ts \ - $$LANG_PATH/qbittorrent_zh.ts \ - $$LANG_PATH/qbittorrent_zh_TW.ts \ + $$LANG_PATH/qbittorrent_zh_Hans.ts \ + $$LANG_PATH/qbittorrent_zh_Hant.ts \ $$LANG_PATH/qbittorrent_en.ts \ $$LANG_PATH/qbittorrent_en_AU.ts \ $$LANG_PATH/qbittorrent_en_GB.ts \ diff --git a/src/webui/www/public/preferences_content.html b/src/webui/www/public/preferences_content.html index 41adb243f..3f82f8f1d 100644 --- a/src/webui/www/public/preferences_content.html +++ b/src/webui/www/public/preferences_content.html @@ -316,8 +316,8 @@ - - + +