v2.0: Full localization (6 languages), first-run language screen, aircraft detail overhaul, aircraft-model API fallback, and multiple bugfixes
This commit is contained in:
37
src/i18n.cpp
Normal file
37
src/i18n.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#include "i18n.h"
|
||||
#include "i18n_en.h"
|
||||
#include "i18n_de.h"
|
||||
#include "i18n_fr.h"
|
||||
#include "i18n_tr.h"
|
||||
#include "i18n_es.h"
|
||||
#include "i18n_it.h"
|
||||
#include "settings_store.h"
|
||||
|
||||
namespace I18n {
|
||||
|
||||
namespace {
|
||||
const char* const* TABLES[LANG_COUNT] = {
|
||||
I18N_EN, I18N_DE, I18N_FR, I18N_TR, I18N_ES, I18N_IT
|
||||
};
|
||||
|
||||
const char* const LANGUAGE_NAMES[LANG_COUNT] = {
|
||||
"English", "Deutsch", "Francais", "Turkce", "Espanol", "Italiano"
|
||||
};
|
||||
}
|
||||
|
||||
const char* t(StringId id) {
|
||||
uint8_t lang = SettingsStore::language();
|
||||
if (lang >= LANG_COUNT) lang = 0;
|
||||
|
||||
uint8_t idx = (uint8_t)id;
|
||||
if (idx >= (uint8_t)StringId::COUNT) return "?";
|
||||
|
||||
return TABLES[lang][idx];
|
||||
}
|
||||
|
||||
const char* languageName(uint8_t index) {
|
||||
if (index >= LANG_COUNT) return "?";
|
||||
return LANGUAGE_NAMES[index];
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user