20 default:
return "config/lang/en.txt";
29 std::ifstream file(filePath);
31 if (!file.is_open()) {
32 log::error(
"Failed to load language file: {}", filePath);
37 while (std::getline(file, line)) {
38 if (line.empty() || line[0] ==
'#')
continue;
40 auto delimPos = line.find(
'=');
41 if (delimPos == std::string::npos)
continue;
43 std::string key = line.substr(0, delimPos);
44 std::string value = line.substr(delimPos + 1);
46 key.erase(0, key.find_first_not_of(
" \t"));
47 key.erase(key.find_last_not_of(
" \t") + 1);
48 value.erase(0, value.find_first_not_of(
" \t"));
49 value.erase(value.find_last_not_of(
" \t") + 1);
54 log::info(
"Loaded {} translations for language: {}",
std::string getLanguageFilePath(Language lang) const
Get file path for a given language.
std::string get(const std::string &key) const
Get translated string for a key.
std::unordered_map< std::string, std::string > _translations
Map of translation keys to translated strings.
bool loadLanguage(Language language)
Load translations for a specific language.
Language _currentLanguage
Currently loaded language.
Language
Supported languages.
void error(LogFmt< std::type_identity_t< Args >... > fmt, Args &&...args) noexcept
Log an error message.
void warning(LogFmt< std::type_identity_t< Args >... > fmt, Args &&...args) noexcept
Log a warning message.
void info(LogFmt< std::type_identity_t< Args >... > fmt, Args &&...args) noexcept
Log an informational message.