diff options
| author | Aldrik Ramaekers <aldrikboy@gmail.com> | 2025-08-09 08:33:08 +0200 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrikboy@gmail.com> | 2025-08-09 08:33:08 +0200 |
| commit | 5d34aff5888d3f0c624251f15bedb96c347978d6 (patch) | |
| tree | 69a49651271d645ca7eaa114cb1830bf759c0930 /src/locales.cpp | |
| parent | b94a7ae06b20d550c727d5192cea8baf3e8fb641 (diff) | |
refactors
Diffstat (limited to 'src/locales.cpp')
| -rw-r--r-- | src/locales.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/locales.cpp b/src/locales.cpp new file mode 100644 index 0000000..6ec1233 --- /dev/null +++ b/src/locales.cpp @@ -0,0 +1,29 @@ +#include "locales.hpp" + +locale_map locales[] = { + {"en", en_locales, en_locale_count}, + // Add new locales here. +}; + +const int locale_map_count = sizeof(locales) / sizeof(locales[0]); + +locale_map g_locale = locales[0]; // Default to english. + +void set_locale(const char* key) +{ + for (int i = 0; i < locale_map_count; ++i) { + if (strcmp(locales[i].lang_code, key) == 0) { + g_locale = locales[i]; + } + } +} + +const char* localize(const char* key) +{ + for (int i = 0; i < g_locale.entry_count; ++i) { + if (strcmp(g_locale.entries[i].key, key) == 0) { + return g_locale.entries[i].value; + } + } + return "[!MISSING!]"; +}
\ No newline at end of file |
