Mercurial > octave
changeset 26866:65e5526ad987
improve system locale detection for loading gui translations (bug #41072)
* resource-manager.cc ((config_translators): if lamguage follows system
settings pass current locale to the qt translator for loading the related
translation files; otherwise derive the name directly from the
preference string
author | Torsten <mttl@mailbox.org> |
---|---|
date | Sat, 09 Mar 2019 17:24:28 +0100 |
parents | dfd0a2cdb621 |
children | 7506884fc158 |
files | libgui/src/resource-manager.cc |
diffstat | 1 files changed, 21 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/resource-manager.cc Fri Mar 08 22:06:32 2019 +0100 +++ b/libgui/src/resource-manager.cc Sat Mar 09 17:24:28 2019 +0100 @@ -125,23 +125,31 @@ language = settings->value ("language", "SYSTEM").toString (); } + // load the translations depending on the settings if (language == "SYSTEM") - language = QLocale::system ().name (); // get system wide locale - - // load the translator file for qt strings - loaded = qt_tr->load ("qt_" + language, qt_trans_dir); - - if (! loaded) // try lower case - qt_tr->load ("qt_" + language.toLower (), qt_trans_dir); + { + // get the system locale and pass it to the translators for loading + // the suitable translation files + QLocale sys_locale = QLocale::system (); - // load the translator file for qscintilla settings - loaded = qsci_tr->load ("qscintilla_" + language, qt_trans_dir); + qt_tr->load (sys_locale, "qt", "_", qt_trans_dir); + qsci_tr->load (sys_locale, "qscintilla", "_", qt_trans_dir); + gui_tr->load (sys_locale, "", "", get_gui_translation_dir ()); + } + else + { + // load the translation files depending on the given locale name + loaded = qt_tr->load ("qt_" + language, qt_trans_dir); + if (! loaded) // try lower case + qt_tr->load ("qt_" + language.toLower (), qt_trans_dir); - if (! loaded) // try lower case - qsci_tr->load ("qscintilla_" + language.toLower (), qt_trans_dir); + loaded = qsci_tr->load ("qscintilla_" + language, qt_trans_dir); + if (! loaded) // try lower case + qsci_tr->load ("qscintilla_" + language.toLower (), qt_trans_dir); - // load the translator file for gui strings - gui_tr->load (language, get_gui_translation_dir ()); + gui_tr->load (language, get_gui_translation_dir ()); + } + } QStringList resource_manager::storage_class_names (void)