Working on translations

This commit is contained in:
Vladislav Khorev committed 2026-07-07 11:24:21 +03:00
1 parent 9d8ca865c7
commit e2d9105b02
18 files changed
+271 -88

No files matched your search

+33
View File
@@ -21,6 +21,39 @@ Language languageFromCode(const std::string& code) {
return Language::Russian;
}
std::string localizedConfigPath(const std::string& basePath, Language lang) {
static const std::string marker = "/config/";
const size_t pos = basePath.find(marker);
if (pos == std::string::npos) return basePath;
return basePath.substr(0, pos) + "/config_" + languageToCode(lang) + "/" + basePath.substr(pos + marker.size());
}
std::string readLocalizedConfigFile(const std::string& basePath, const std::string& zipFile) {
const std::string localizedPath = localizedConfigPath(basePath, g_currentLanguage);
if (localizedPath != basePath) {
std::string content;
if (zipFile.empty()) {
content = readTextFile(localizedPath);
} else {
try {
const auto buf = readFileFromZIP(localizedPath, zipFile);
content.assign(buf.begin(), buf.end());
} catch (const std::exception&) {
content.clear();
}
}
if (!content.empty()) return content;
}
if (zipFile.empty()) return readTextFile(basePath);
try {
const auto buf = readFileFromZIP(basePath, zipFile);
return std::string(buf.begin(), buf.end());
} catch (const std::exception&) {
return "";
}
}
void loadLanguageSetting() {
const std::string content = readTextFile("settings.json");
if (content.empty()) return;