Commit a11df1a8 authored by Guillaume Roguez's avatar Guillaume Roguez

i18n: loads language code only and full locale name for lrc

Qt loads only one specific file with QTranslate.load().
So if for example locale name is 'fr_CA', only this specific
translation will be loaded, but not 'fr', that may contains
usefull generic translations not given by lang_country one.

This patch fixes that by loading language code only fist
then 'language_COUNTRY' one.

Change-Id: I11a5adbd55f6575aab5453df0033377967ccc17e
Reviewed-by: default avatarAnthony Léonard <anthony.leonard@savoirfairelinux.com>
parent 44480d65
......@@ -112,18 +112,35 @@ main(int argc, char *argv[])
ShmClient* shmClient = new ShmClient(shm, sem);
#endif
QTranslator qtTranslator;
qtTranslator.load("qt_" + QLocale::system().name(),
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
a.installTranslator(&qtTranslator);
QTranslator lrcTranslator;
lrcTranslator.load("share/libringclient/translations/lrc_" + QLocale::system().name());
a.installTranslator(&lrcTranslator);
QTranslator mainTranslator;
mainTranslator.load("share/ring/translations/ring_client_windows_" + QLocale::system().name());
a.installTranslator(&mainTranslator);
const auto locale_name = QLocale::system().name();
const auto locale_lang = locale_name.split('_')[0];
QTranslator qtTranslator_lang;
QTranslator qtTranslator_name;
if (locale_name != locale_lang) {
qtTranslator_lang.load("qt_" + locale_lang, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
a.installTranslator(&qtTranslator_lang);
}
qtTranslator_name.load("qt_" + locale_name, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
a.installTranslator(&qtTranslator_name);
QTranslator lrcTranslator_lang;
QTranslator lrcTranslator_name;
if (locale_name != locale_lang) {
lrcTranslator_lang.load("share/libringclient/translations/lrc_" + locale_lang);
a.installTranslator(&lrcTranslator_lang);
}
lrcTranslator_name.load("share/libringclient/translations/lrc_" + locale_name);
a.installTranslator(&lrcTranslator_name);
QTranslator mainTranslator_lang;
QTranslator mainTranslator_name;
if (locale_name != locale_lang) {
mainTranslator_lang.load("share/ring/translations/ring_client_windows_" + locale_lang);
a.installTranslator(&mainTranslator_lang);
}
mainTranslator_name.load("share/ring/translations/ring_client_windows_" + locale_name);
a.installTranslator(&mainTranslator_name);
QFont font;
font.setFamily("Segoe UI");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment