From fec6c8af274d33b37b33f8feb937f80f8df1e0da 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 fa4a7f62b..d1621cfea 100644 --- a/src/app/application.cpp +++ b/src/app/application.cpp @@ -253,8 +253,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 33a640794..1292c16ea 100644 --- a/src/gui/options_imp.cpp +++ b/src/gui/options_imp.cpp @@ -1076,7 +1076,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 ) { @@ -1361,7 +1373,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 5313d2fdf..633a00e29 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 5f348afca..300d148a7 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 2c233f1e4..2b59b8043 100644 --- a/src/src.pro +++ b/src/src.pro @@ -73,8 +73,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 @@ - - + +