This commit is contained in:
QwQ 2020-08-02 09:04:52 +08:00
parent 311f7ee294
commit a62db8de1d
2 changed files with 12 additions and 5 deletions

View File

@ -1 +1 @@
5819
5820

View File

@ -396,11 +396,17 @@ namespace Qv2ray
// Load config object from upgraded config QJsonObject
auto confObject = Qv2rayConfigObject::fromJson(conf);
if (!Qv2rayTranslator->GetAvailableLanguages().contains(confObject.uiConfig.language))
const auto allTranslations = Qv2rayTranslator->GetAvailableLanguages();
const auto osLanguage = QLocale::system().name();
if (!allTranslations.contains(confObject.uiConfig.language) && allTranslations.contains(osLanguage))
{
// Prevent empty.
LOG(MODULE_UI, "Setting default UI language to system locale.")
confObject.uiConfig.language = QLocale::system().name();
// If configured language is not found. Set to system language.
LOG(MODULE_UI, "Fall back language setting to: " + osLanguage)
confObject.uiConfig.language = osLanguage;
}
else if (!allTranslations.isEmpty())
{
confObject.uiConfig.language = allTranslations.first();
}
if (!Qv2rayTranslator->InstallTranslation(confObject.uiConfig.language))
@ -409,6 +415,7 @@ namespace Qv2ray
"Cannot load translation for " + confObject.uiConfig.language + NEWLINE + //
"English is now used." + NEWLINE + NEWLINE + //
"Please go to Preferences Window to change language or open an Issue");
confObject.uiConfig.language = "en_US";
}
// Let's save the config.