Working on translations and minor bugs fix

This commit is contained in:
Vladislav Khorev committed 2026-07-07 20:27:46 +03:00
1 parent a40a582b5a
commit c6ba8bd008
9 files changed
+75 -9

No files matched your search

+17
View File
@@ -77,4 +77,21 @@ std::string TranslationDatabase::translate(const std::string& key, Language lang
return key;
}
const std::string& TranslationDatabase::translateRef(const std::string& key, Language lang) const {
if (key.empty()) return key;
auto it = entries.find(key);
if (it == entries.end()) return key;
const auto& langMap = it->second;
auto langIt = langMap.find(languageToCode(lang));
if (langIt != langMap.end() && !langIt->second.empty()) return langIt->second;
auto ruIt = langMap.find("ru");
if (ruIt != langMap.end() && !ruIt->second.empty()) return ruIt->second;
return key;
}
} // namespace ZL::Dialogue
+1
View File
@@ -18,6 +18,7 @@ public:
// Returns the translated text for `key` in `lang`, falling back to Russian,
// then to `key` itself if no entry or translation exists.
std::string translate(const std::string& key, Language lang) const;
const std::string& translateRef(const std::string& key, Language lang) const;
private:
std::unordered_map<std::string, std::unordered_map<std::string, std::string>> entries;