1
0
mirror of synced 2024-11-24 15:50:16 +01:00

impr: Only reload localization when necessary

This commit is contained in:
WerWolv 2023-07-09 20:24:56 +02:00
parent 6343cb092b
commit ce9ce42c1c
3 changed files with 12 additions and 1 deletions

View File

@ -39,10 +39,13 @@ namespace hex {
static void resetLanguageStrings();
static const std::string &getSelectedLanguage();
private:
std::string m_unlocalizedString;
static std::string s_fallbackLanguage;
static std::string s_selectedLanguage;
static std::map<std::string, std::string> s_currStrings;
};

View File

@ -5,6 +5,7 @@
namespace hex {
std::string LangEntry::s_fallbackLanguage;
std::string LangEntry::s_selectedLanguage;
std::map<std::string, std::string> LangEntry::s_currStrings;
LanguageDefinition::LanguageDefinition(std::map<std::string, std::string> &&entries) {
@ -89,6 +90,8 @@ namespace hex {
for (auto &definition : definitions[fallbackLanguage])
LangEntry::s_currStrings.insert(definition.getEntries().begin(), definition.getEntries().end());
}
LangEntry::s_selectedLanguage = language;
}
const std::map<std::string, std::string> &LangEntry::getSupportedLanguages() {
@ -107,4 +110,8 @@ namespace hex {
LangEntry::s_currStrings.clear();
}
const std::string &LangEntry::getSelectedLanguage() {
return s_selectedLanguage;
}
}

View File

@ -403,7 +403,8 @@ namespace hex::plugin::builtin {
{
auto language = ContentRegistry::Settings::read("hex.builtin.setting.interface", "hex.builtin.setting.interface.language", "en-US");
LangEntry::loadLanguage(language);
if (language != LangEntry::getSelectedLanguage())
LangEntry::loadLanguage(language);
}
{