diff --git a/res/localization/LameXP_TW.qm.txt b/res/localization/LameXP_TW.qm.txt index 35cce7f5..8131ec8a 100644 --- a/res/localization/LameXP_TW.qm.txt +++ b/res/localization/LameXP_TW.qm.txt @@ -1 +1 @@ -25,6,繁体中文 \ No newline at end of file +25,208,繁体中文 \ No newline at end of file diff --git a/res/localization/LameXP_ZH.qm.txt b/res/localization/LameXP_ZH.qm.txt index 92b22a77..10f90b7e 100644 --- a/res/localization/LameXP_ZH.qm.txt +++ b/res/localization/LameXP_ZH.qm.txt @@ -1 +1 @@ -25,5,简体中文 \ No newline at end of file +25,44,简体中文 \ No newline at end of file diff --git a/src/Config.h b/src/Config.h index 467b1be3..ac69ec1c 100644 --- a/src/Config.h +++ b/src/Config.h @@ -30,7 +30,7 @@ #define VER_LAMEXP_MINOR_LO 4 #define VER_LAMEXP_TYPE Alpha #define VER_LAMEXP_PATCH 10 -#define VER_LAMEXP_BUILD 819 +#define VER_LAMEXP_BUILD 820 /////////////////////////////////////////////////////////////////////////////// // Tool versions (minimum expected versions!) diff --git a/src/Global.cpp b/src/Global.cpp index 47aefddf..be5c8c04 100644 --- a/src/Global.cpp +++ b/src/Global.cpp @@ -186,7 +186,7 @@ static struct QMap files; QMap names; QMap sysid; - QMap scrpt; + QMap cntry; } g_lamexp_translation; @@ -1252,7 +1252,7 @@ const QString lamexp_version2string(const QString &pattern, unsigned int version /* * Register a new translation */ -bool lamexp_translation_register(const QString &langId, const QString &qmFile, const QString &langName, unsigned int &systemId, unsigned int &script) +bool lamexp_translation_register(const QString &langId, const QString &qmFile, const QString &langName, unsigned int &systemId, unsigned int &country) { if(qmFile.isEmpty() || langName.isEmpty() || systemId < 1) { @@ -1262,7 +1262,7 @@ bool lamexp_translation_register(const QString &langId, const QString &qmFile, c g_lamexp_translation.files.insert(langId, qmFile); g_lamexp_translation.names.insert(langId, langName); g_lamexp_translation.sysid.insert(langId, systemId); - g_lamexp_translation.scrpt.insert(langId, script); + g_lamexp_translation.cntry.insert(langId, country); return true; } @@ -1294,9 +1294,9 @@ unsigned int lamexp_translation_sysid(const QString &langId) /* * Get translation script id */ -unsigned int lamexp_translation_script(const QString &langId) +unsigned int lamexp_translation_country(const QString &langId) { - return g_lamexp_translation.scrpt.value(langId.toLower(), 0); + return g_lamexp_translation.cntry.value(langId.toLower(), 0); } /* diff --git a/src/Global.h b/src/Global.h index cc850adf..2f624ac6 100644 --- a/src/Global.h +++ b/src/Global.h @@ -111,10 +111,10 @@ bool lamexp_is_hibernation_supported(void); //Translation support QStringList lamexp_query_translations(void); -bool lamexp_translation_register(const QString &langId, const QString &qmFile, const QString &langName, unsigned int &systemId, unsigned int &script); +bool lamexp_translation_register(const QString &langId, const QString &qmFile, const QString &langName, unsigned int &systemId, unsigned int &country); QString lamexp_translation_name(const QString &language); unsigned int lamexp_translation_sysid(const QString &langId); -unsigned int lamexp_translation_script(const QString &langId); +unsigned int lamexp_translation_country(const QString &langId); bool lamexp_install_translator_from_file(const QString &qmFile); bool lamexp_install_translator(const QString &language); QStringList lamexp_available_codepages(bool noAliases = true); diff --git a/src/Model_Settings.cpp b/src/Model_Settings.cpp index 0e7a7d98..79d70f66 100644 --- a/src/Model_Settings.cpp +++ b/src/Model_Settings.cpp @@ -271,23 +271,28 @@ QString SettingsModel::defaultLanguage(void) return *m_defaultLanguage; } - //Check if we can use the default translation + //Detect system langauge QLocale systemLanguage= QLocale::system(); + qDebug("[Locale]"); + qDebug("Language: %s (%d)", QLocale::languageToString(systemLanguage.language()).toUtf8().constData(), systemLanguage.language()); + qDebug("Country is: %s (%d)", QLocale::countryToString(systemLanguage.country()).toUtf8().constData(), systemLanguage.country()); + qDebug("Script is: %s (%d)\n", QLocale::scriptToString(systemLanguage.script()).toUtf8().constData(), systemLanguage.script()); + + //Check if we can use the default translation if(systemLanguage.language() == QLocale::English /*|| systemLanguage.language() == QLocale::C*/) { m_defaultLanguage = new QString(LAMEXP_DEFAULT_LANGID); return LAMEXP_DEFAULT_LANGID; } - //Try to find a suitable translation for the user's system language + //Try to find a suitable translation for the user's system language *and* country QStringList languages = lamexp_query_translations(); while(!languages.isEmpty()) { QString currentLangId = languages.takeFirst(); if(lamexp_translation_sysid(currentLangId) == systemLanguage.language()) { - unsigned int script = lamexp_translation_script(currentLangId); - if((script == 0) || (systemLanguage.script() == 0) || (script == systemLanguage.script())) + if(lamexp_translation_country(currentLangId) == systemLanguage.country()) { m_defaultLanguage = new QString(currentLangId); return currentLangId; @@ -295,6 +300,18 @@ QString SettingsModel::defaultLanguage(void) } } + //Try to find a suitable translation for the user's system language + languages = lamexp_query_translations(); + while(!languages.isEmpty()) + { + QString currentLangId = languages.takeFirst(); + if(lamexp_translation_sysid(currentLangId) == systemLanguage.language()) + { + m_defaultLanguage = new QString(currentLangId); + return currentLangId; + } + } + //Fall back to the default translation m_defaultLanguage = new QString(LAMEXP_DEFAULT_LANGID); return LAMEXP_DEFAULT_LANGID;