Files
horizon-airdef/launcher/src/language_page.rs
T
Ludovic Marie b3709b9766 launcher: French and Russian, following the system's language
A string table per language (launcher/lang/<code>.json, English text to its translation)
and tr()/trf() in i18n.rs. The window follows the system's language unless Settings >
Launcher > Language picks one; a missing string shows in English. This first part
translates the top bar, the account switch and the Settings page's account, update and
launcher rows; buttons, segments, section titles and page headers translate through their
widgets. CLI: settings language system|en|fr|ru.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 04:58:31 +01:00

36 lines
1.3 KiB
Rust

//! Settings' Language row (`horizon_launcher::i18n`): the system's language, or one the player
//! picks, each named in itself.
use super::*;
use horizon_launcher::i18n::Language;
impl Launcher {
pub(super) fn language_row(&self, cx: &mut Context<Self>) -> Div {
let t = self.theme;
let mut options = vec![(None, "System")];
options.extend(Language::ALL.map(|l| (Some(l), l.name())));
let picker = segments("language", &options, self.settings.language, &t, {
let this = cx.entity().downgrade();
move |choice, _, cx| {
let _ = this.update(cx, |this, cx| {
this.settings.language = choice;
this.settings.save();
i18n::set(this.settings.language());
cx.notify();
});
}
});
let said = trf(
"System follows your computer's language: {language} here. A string not translated \
yet shows in English.",
&[("language", Language::system().name())],
);
index_row(
0,
tr("Language"),
Some(div().child(said).into_any_element()),
Some(picker.into_any_element()),
&t,
)
}
}