mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-06-12 15:03:15 +02:00
Fix regional system locale loading the wrong translation (#421)
langFromSetting() truncated the system locale to two letters (QLocale::system().name().left(2)), so a user on the default 'Système' language whose locale is regional got the base-language translation instead of their regional one. QET ships qet_pt_BR, qet_nl_BE and qet_nl_NL, so e.g. a Brazilian user saw European Portuguese (and untranslated strings fell back to the French source). Keep the full locale name and, in setLanguage(), try the exact translation, then the base language, then English (French stays the native source). Brazilian/Belgian/Dutch users on 'system' now get their regional translation; everyone else is unaffected. Refs #421.
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