Working on translations for dialogs and cutscenes

This commit is contained in:
Vladislav Khorev committed 2026-07-05 21:52:37 +03:00
1 parent a98f71676d
commit 794a820be9
25 files changed
+3015 -123

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
#include "Localization.h"
#include "external/nlohmann/json.hpp"
#include "utils/Utils.h"
#include <iostream>
namespace ZL {
Language g_currentLanguage = Language::Russian;
std::string languageToCode(Language lang) {
switch (lang) {
case Language::English: return "en";
case Language::Russian:
default: return "ru";
}
}
Language languageFromCode(const std::string& code) {
if (code == "en") return Language::English;
return Language::Russian;
}
void loadLanguageSetting() {
const std::string content = readTextFile("settings.json");
if (content.empty()) return;
try {
const nlohmann::json root = nlohmann::json::parse(content);
if (root.contains("language")) {
g_currentLanguage = languageFromCode(root["language"].get<std::string>());
}
} catch (const std::exception& e) {
std::cerr << "[settings] Failed to parse settings.json: " << e.what() << std::endl;
}
}
} // namespace ZL