diff --git a/lib/libimhex/include/hex/api/localization.hpp b/lib/libimhex/include/hex/api/localization.hpp index 723a9a428..036a8770f 100644 --- a/lib/libimhex/include/hex/api/localization.hpp +++ b/lib/libimhex/include/hex/api/localization.hpp @@ -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 s_currStrings; }; diff --git a/lib/libimhex/source/api/localization.cpp b/lib/libimhex/source/api/localization.cpp index 85eaea49a..f91d79f23 100644 --- a/lib/libimhex/source/api/localization.cpp +++ b/lib/libimhex/source/api/localization.cpp @@ -5,6 +5,7 @@ namespace hex { std::string LangEntry::s_fallbackLanguage; + std::string LangEntry::s_selectedLanguage; std::map LangEntry::s_currStrings; LanguageDefinition::LanguageDefinition(std::map &&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 &LangEntry::getSupportedLanguages() { @@ -107,4 +110,8 @@ namespace hex { LangEntry::s_currStrings.clear(); } + const std::string &LangEntry::getSelectedLanguage() { + return s_selectedLanguage; + } + } \ No newline at end of file diff --git a/plugins/builtin/source/content/welcome_screen.cpp b/plugins/builtin/source/content/welcome_screen.cpp index ae9564a87..7ba0880d9 100644 --- a/plugins/builtin/source/content/welcome_screen.cpp +++ b/plugins/builtin/source/content/welcome_screen.cpp @@ -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); } {