mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2025-03-14 01:32:25 +01:00
Merge 4d1a2c75c6c205601763aac07085f58cacb7f5be into 42d77cd720eb42845c2afb77c6d7157e02c8c325
This commit is contained in:
commit
391981c53a
@ -3537,16 +3537,31 @@ void GMainWindow::LoadTranslation() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool loaded;
|
QString language = UISettings::values.language;
|
||||||
|
|
||||||
if (UISettings::values.language.isEmpty()) {
|
if (language.isEmpty()) {
|
||||||
// Use the system's default locale
|
#ifdef _WIN32
|
||||||
loaded = translator.load(QLocale::system(), {}, {}, QStringLiteral(":/languages/"));
|
LANGID lang_id = GetUserDefaultUILanguage();
|
||||||
} else {
|
wchar_t locale_name[LOCALE_NAME_MAX_LENGTH];
|
||||||
// Otherwise load from the specified file
|
|
||||||
loaded = translator.load(UISettings::values.language, QStringLiteral(":/languages/"));
|
if (LCIDToLocaleName(MAKELCID(lang_id, SORT_DEFAULT), locale_name, LOCALE_NAME_MAX_LENGTH,
|
||||||
|
0)) {
|
||||||
|
char locale_name_str[LOCALE_NAME_MAX_LENGTH];
|
||||||
|
WideCharToMultiByte(CP_UTF8, 0, locale_name, -1, locale_name_str,
|
||||||
|
LOCALE_NAME_MAX_LENGTH, nullptr, nullptr);
|
||||||
|
language = QString::fromUtf8(locale_name_str);
|
||||||
|
} else {
|
||||||
|
language = QLocale::system().name();
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
language = QLocale::system().name();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For compatibility with translation files
|
||||||
|
language.replace(QLatin1Char('-'), QLatin1Char('_'));
|
||||||
|
|
||||||
|
bool loaded = translator.load(language, QStringLiteral(":/languages/"));
|
||||||
if (loaded) {
|
if (loaded) {
|
||||||
qApp->installTranslator(&translator);
|
qApp->installTranslator(&translator);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user