mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-06-14 00:43:14 +02:00
Merge pull request #496 from ispyisail/fix-system-regional-locale
Fix regional system locale loading the wrong translation (pt_BR/nl_BE/nl_NL)
This commit is contained in:
+19
-15
@@ -226,20 +226,20 @@ void QETApp::setLanguage(const QString &desired_language) {
|
|||||||
|
|
||||||
// load translations for the QET application
|
// load translations for the QET application
|
||||||
// charge les traductions pour l'application QET
|
// charge les traductions pour l'application QET
|
||||||
if (!qetTranslator.load("qet_" + desired_language, languages_path)) {
|
// desired_language may be a full locale such as "pt_BR": try that exact
|
||||||
/* in case of failure,
|
// translation, then the base language ("pt"), then fall back to English.
|
||||||
* we fall back on the native channels for French
|
// French is the application's source language and needs no translation.
|
||||||
* en cas d'echec,
|
const QString base_language = desired_language.section('_', 0, 0);
|
||||||
* on retombe sur les chaines natives pour le francais
|
bool loaded = qetTranslator.load("qet_" + desired_language, languages_path);
|
||||||
*/
|
if (!loaded && base_language != desired_language)
|
||||||
if (desired_language != "fr") {
|
loaded = qetTranslator.load("qet_" + base_language, languages_path);
|
||||||
// use of the English version by default
|
if (!loaded && base_language != "fr") {
|
||||||
// utilisation de la version anglaise par defaut
|
// use of the English version by default
|
||||||
if(!qetTranslator.load("qet_en", languages_path))
|
// utilisation de la version anglaise par defaut
|
||||||
qWarning() << "failed to load"
|
if(!qetTranslator.load("qet_en", languages_path))
|
||||||
<< "qet_en" << languages_path << "(" << __FILE__
|
qWarning() << "failed to load"
|
||||||
<< __LINE__ << __FUNCTION__ << ")";
|
<< "qet_en" << languages_path << "(" << __FILE__
|
||||||
}
|
<< __LINE__ << __FUNCTION__ << ")";
|
||||||
}
|
}
|
||||||
qApp->installTranslator(&qetTranslator);
|
qApp->installTranslator(&qetTranslator);
|
||||||
|
|
||||||
@@ -263,7 +263,11 @@ QString QETApp::langFromSetting()
|
|||||||
QSettings settings;
|
QSettings settings;
|
||||||
system_language = settings.value("lang", "system").toString();
|
system_language = settings.value("lang", "system").toString();
|
||||||
if(system_language == "system") {
|
if(system_language == "system") {
|
||||||
system_language = QLocale::system().name().left(2);
|
// Keep the full locale (e.g. "pt_BR"), not just the base language
|
||||||
|
// ("pt"): QET ships regional translations (pt_BR, nl_BE, nl_NL) and
|
||||||
|
// truncating here loaded the wrong one. setLanguage() falls back to
|
||||||
|
// the base language when no regional translation exists.
|
||||||
|
system_language = QLocale::system().name();
|
||||||
}
|
}
|
||||||
lang_is_set = true;
|
lang_is_set = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user