mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2025-03-21 13:08:38 +01:00
lime_qt: Switch to GetUserDefaultUILanguage
to fetch active display language on Windows
This commit is contained in:
parent
a5ad887771
commit
d4b96557b8
@ -3515,16 +3515,32 @@ 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/"));
|
// Use Windows API to get the active display language
|
||||||
|
LANGID lang_id = GetUserDefaultUILanguage();
|
||||||
|
wchar_t locale_name[LOCALE_NAME_MAX_LENGTH];
|
||||||
|
|
||||||
|
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 {
|
} else {
|
||||||
// Otherwise load from the specified file
|
language = QLocale::system().name();
|
||||||
loaded = translator.load(UISettings::values.language, QStringLiteral(":/languages/"));
|
}
|
||||||
|
#else
|
||||||
|
language = QLocale::system().name();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Replace dashes with underscores 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 {
|
||||||
|
@ -321,6 +321,9 @@ private:
|
|||||||
GameListPlaceholder* game_list_placeholder;
|
GameListPlaceholder* game_list_placeholder;
|
||||||
LoadingScreen* loading_screen;
|
LoadingScreen* loading_screen;
|
||||||
|
|
||||||
|
// General
|
||||||
|
QString current_language;
|
||||||
|
|
||||||
// Status bar elements
|
// Status bar elements
|
||||||
QProgressBar* progress_bar = nullptr;
|
QProgressBar* progress_bar = nullptr;
|
||||||
QLabel* message_label = nullptr;
|
QLabel* message_label = nullptr;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user