languages.sleela
lib/languages/languages.sleela · 158 line(s) · sleela
#sleela 2.5
material;
< languages.sleela -- the self-contained, runnable build of the SLeeLa >
< localization library. The compiler's `run` compiles one file as a single >
< unit, so this aggregate carries the translations inline and a `main` that >
< prints a few messages in several languages. The split per-class files >
< (SLLanguage.sleela, SLLanguageCatalog.sleela) are the package discovery >
< surface; the canonical, tool-readable translation data lives in the >
< repository's /languages/<code>.lang files, which this mirrors. >
< >
< SLeeLa decides what to say; the active language decides how it is said. >
< Supported locales mirror /languages: en es fr de pt it ja zh hi ar. >
class Languages {
< ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- >
<< Eleven catalogued attributes with getter/setter pairs, so a GUI, loader,
or catalog can read and (where appropriate) override this record.
Values are faithful to the subject's real origin where publicly known. >>
String metaVersion = "1.0.0";
int metaId = 10062;
String metaAuthor = "Kiro Agent";
String metaDate = "2026-10-16";
String metaCopyright = "SLeeLa project";
String metaTrademark = "none";
String metaCorporation = "none";
< metaOrigin: National | <nation> | International | Galactic >
String metaOrigin = "International";
String metaBirthDate = "2026-10-04";
< metaScienceRating: maturity/robustness on a 1..10 scale >
int metaScienceRating = 9;
< metaNationalSchedule: a real, citable instrument or "none" >
String metaNationalSchedule = "none";
String getMetaVersion() { return metaVersion; }
void setMetaVersion(String v) { metaVersion = v; }
int getMetaId() { return metaId; }
void setMetaId(int v) { metaId = v; }
String getAuthor() { return metaAuthor; }
void setAuthor(String v) { metaAuthor = v; }
String getDate() { return metaDate; }
void setDate(String v) { metaDate = v; }
String getCopyright() { return metaCopyright; }
void setCopyright(String v) { metaCopyright = v; }
String getTrademark() { return metaTrademark; }
void setTrademark(String v) { metaTrademark = v; }
String getCorporation() { return metaCorporation; }
void setCorporation(String v) { metaCorporation = v; }
String getOrigin() { return metaOrigin; }
void setOrigin(String v) { metaOrigin = v; }
String getBirthDate() { return metaBirthDate; }
void setBirthDate(String v) { metaBirthDate = v; }
int getScienceRating() { return metaScienceRating; }
void setScienceRating(int v) { metaScienceRating = v; }
String getNationalSchedule() { return metaNationalSchedule; }
void setNationalSchedule(String v) { metaNationalSchedule = v; }
< Translate one message key into the given locale. Falls back to English >
< for an unknown locale or key. Only a representative subset of the full >
< key set (see /languages/KEYS.md) is shown here for the demonstration. >
String text(String locale, String key) {
if (locale == "es") {
if (key == "greeting.hello") { return "Hola"; }
if (key == "greeting.welcome") { return "Bienvenido"; }
if (key == "prompt.continue") { return "¿Continuar?"; }
if (key == "word.yes") { return "Sí"; }
if (key == "word.no") { return "No"; }
if (key == "status.done") { return "Hecho"; }
}
if (locale == "fr") {
if (key == "greeting.hello") { return "Bonjour"; }
if (key == "greeting.welcome") { return "Bienvenue"; }
if (key == "prompt.continue") { return "Continuer ?"; }
if (key == "word.yes") { return "Oui"; }
if (key == "word.no") { return "Non"; }
if (key == "status.done") { return "Terminé"; }
}
if (locale == "de") {
if (key == "greeting.hello") { return "Hallo"; }
if (key == "greeting.welcome") { return "Willkommen"; }
if (key == "prompt.continue") { return "Fortfahren?"; }
if (key == "word.yes") { return "Ja"; }
if (key == "word.no") { return "Nein"; }
if (key == "status.done") { return "Fertig"; }
}
if (locale == "ja") {
if (key == "greeting.hello") { return "こんにちは"; }
if (key == "greeting.welcome") { return "ようこそ"; }
if (key == "prompt.continue") { return "続けますか?"; }
if (key == "word.yes") { return "はい"; }
if (key == "word.no") { return "いいえ"; }
if (key == "status.done") { return "完了"; }
}
if (locale == "ko") {
if (key == "greeting.hello") { return "안녕하세요"; }
if (key == "greeting.welcome") { return "환영합니다"; }
if (key == "prompt.continue") { return "계속하시겠습니까?"; }
if (key == "word.yes") { return "예"; }
if (key == "word.no") { return "아니요"; }
if (key == "status.done") { return "완료"; }
}
if (locale == "th") {
if (key == "greeting.hello") { return "สวัสดี"; }
if (key == "greeting.welcome") { return "ยินดีต้อนรับ"; }
if (key == "prompt.continue") { return "ดำเนินการต่อหรือไม่?"; }
if (key == "word.yes") { return "ใช่"; }
if (key == "word.no") { return "ไม่"; }
if (key == "status.done") { return "เสร็จสิ้น"; }
}
if (locale == "ar") {
if (key == "greeting.hello") { return "مرحبا"; }
if (key == "greeting.welcome") { return "أهلا وسهلا"; }
if (key == "prompt.continue") { return "متابعة؟"; }
if (key == "word.yes") { return "نعم"; }
if (key == "word.no") { return "لا"; }
if (key == "status.done") { return "تم"; }
}
< English reference / fallback. >
if (key == "greeting.hello") { return "Hello"; }
if (key == "greeting.welcome") { return "Welcome"; }
if (key == "prompt.continue") { return "Continue?"; }
if (key == "word.yes") { return "Yes"; }
if (key == "word.no") { return "No"; }
if (key == "status.done") { return "Done"; }
< unknown key: return the key itself >
return key;
}
void greetIn(String locale) {
print(locale + ": " + text(locale, "greeting.hello") + " / "
+ text(locale, "prompt.continue") + " / " + text(locale, "word.yes"));
}
< Resolve the active locale from settings: an explicit override (e.g. the >
< SLEELA_LANG value a launcher supplies) wins; otherwise the configured >
< active locale. Mirrors languages/settings.conf and SLLanguageSettings. >
String resolveActive(String configuredActive, String override) {
if (override != "") { return override; }
if (configuredActive == "") { return "en"; }
return configuredActive;
}
void main() {
< The same program, the same logic -- presented in each language. >
greetIn("en");
greetIn("es");
greetIn("fr");
greetIn("de");
greetIn("ja");
greetIn("ko");
greetIn("th");
greetIn("ar");
< Settings-driven selection: with settings.conf active = "th" and no >
< override, output is presented in Thai. >
String active = resolveActive("th", "");
print("active=" + active + ": " + text(active, "greeting.welcome"));
}
}