impr: Only reload localization when necessary
This commit is contained in:
parent
6343cb092b
commit
ce9ce42c1c
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user