From e30166f23bad89819e505fa1b2abd865cdafd63b Mon Sep 17 00:00:00 2001 From: Alexander Krylov Date: Sun, 25 Oct 2026 02:51:11 +0300 Subject: [PATCH 1/2] Options: Horizon's own captions read a bundled language namespace (#1672) The settings screen's own options (controller, vibration, dead zones and the rest) are not vanilla options and have no vanilla keys, so their captions were English literals. They now read horizon.options.* from assets/horizon/lang, which the client bundles as one more language source placed first, so a pack or the prepared root can still override it. English and Russian ship here. --- .../assets/horizon/lang/en_us.json | 16 +++++++++ .../assets/horizon/lang/ru_ru.json | 16 +++++++++ crates/horizon-client/src/lang.rs | 33 +++++++++++++++++++ crates/horizon-client/src/options_ui.rs | 29 ++++++++-------- 4 files changed, 80 insertions(+), 14 deletions(-) create mode 100644 crates/horizon-client/assets/horizon/lang/en_us.json create mode 100644 crates/horizon-client/assets/horizon/lang/ru_ru.json diff --git a/crates/horizon-client/assets/horizon/lang/en_us.json b/crates/horizon-client/assets/horizon/lang/en_us.json new file mode 100644 index 000000000..056162553 --- /dev/null +++ b/crates/horizon-client/assets/horizon/lang/en_us.json @@ -0,0 +1,16 @@ +{ + "horizon.menu.friends": "Friends", + "horizon.options.controller": "Controller", + "horizon.options.vibration": "Vibration", + "horizon.options.adaptive_triggers": "Adaptive Triggers", + "horizon.options.lightbar": "Lightbar", + "horizon.options.look_sensitivity": "Look Sensitivity", + "horizon.options.invert_x": "Invert Look X", + "horizon.options.invert_y": "Invert Look Y", + "horizon.options.sneak_button": "Sneak Button", + "horizon.options.move_deadzone": "Move Deadzone", + "horizon.options.look_deadzone": "Look Deadzone", + "horizon.options.button_glyphs": "Button Glyphs", + "horizon.options.menu_navigation": "Menu Navigation", + "horizon.options.on_screen_keyboard": "On-Screen Keyboard" +} diff --git a/crates/horizon-client/assets/horizon/lang/ru_ru.json b/crates/horizon-client/assets/horizon/lang/ru_ru.json new file mode 100644 index 000000000..1152f3669 --- /dev/null +++ b/crates/horizon-client/assets/horizon/lang/ru_ru.json @@ -0,0 +1,16 @@ +{ + "horizon.menu.friends": "Друзья", + "horizon.options.controller": "Геймпад", + "horizon.options.vibration": "Вибрация", + "horizon.options.adaptive_triggers": "Адаптивные триггеры", + "horizon.options.lightbar": "Подсветка", + "horizon.options.look_sensitivity": "Чувствительность обзора", + "horizon.options.invert_x": "Инверсия обзора по X", + "horizon.options.invert_y": "Инверсия обзора по Y", + "horizon.options.sneak_button": "Кнопка приседания", + "horizon.options.move_deadzone": "Мёртвая зона движения", + "horizon.options.look_deadzone": "Мёртвая зона обзора", + "horizon.options.button_glyphs": "Символы кнопок", + "horizon.options.menu_navigation": "Навигация по меню", + "horizon.options.on_screen_keyboard": "Экранная клавиатура" +} diff --git a/crates/horizon-client/src/lang.rs b/crates/horizon-client/src/lang.rs index 15f47285a..f761e1199 100644 --- a/crates/horizon-client/src/lang.rs +++ b/crates/horizon-client/src/lang.rs @@ -29,6 +29,22 @@ pub const DEFAULT: &str = "en_us"; static CURRENT: RwLock>> = RwLock::new(None); +/// Horizon's own strings, compiled in so they need no prepared resources. +struct Bundled; +impl ResourceSource for Bundled { + fn read(&self, path: &str) -> Option> { + let body = match path { + "assets/horizon/lang/en_us.json" => include_str!("../assets/horizon/lang/en_us.json"), + "assets/horizon/lang/ru_ru.json" => include_str!("../assets/horizon/lang/ru_ru.json"), + _ => return None, + }; + Some(body.as_bytes().to_vec()) + } + fn namespaces(&self) -> Vec { + vec!["horizon".into()] + } +} + /// A source of resource files: the prepared root plus packs, highest priority last. pub trait ResourceSource { fn read(&self, path: &str) -> Option>; @@ -86,6 +102,12 @@ impl Language { if code != DEFAULT { codes.push(code); } + // Horizon's own strings first, so a pack or the prepared root can still + // override them. Vanilla has no key for "Controller vibration". + let bundled = Bundled; + let mut all: Vec<&dyn ResourceSource> = vec![&bundled]; + all.extend_from_slice(sources); + let sources = all.as_slice(); let namespaces: std::collections::BTreeSet = sources.iter().flat_map(|s| s.namespaces()).collect(); for c in codes { @@ -204,6 +226,17 @@ mod tests { self.0.get(path).cloned() } } + #[test] + fn bundled_horizon_strings_follow_the_language() { + // No prepared resources at all: the namespace is compiled in. + let empty = Mem(HashMap::new()); + let en = Language::load(&[&empty], "en_us"); + assert_eq!(en.get("horizon.options.controller"), Some("Controller")); + let ru = Language::load(&[&empty], "ru_ru"); + assert_eq!(ru.get("horizon.options.controller"), Some("Геймпад")); + assert_eq!(ru.get("horizon.menu.friends"), Some("Друзья")); + } + #[test] fn layers_selected_language_over_english() { let base = Mem(HashMap::from([ diff --git a/crates/horizon-client/src/options_ui.rs b/crates/horizon-client/src/options_ui.rs index 99a83072f..d344c2df8 100644 --- a/crates/horizon-client/src/options_ui.rs +++ b/crates/horizon-client/src/options_ui.rs @@ -267,20 +267,21 @@ impl Opt { Opt::HighContrastBlockOutlines => "options.accessibility.high_contrast_block_outline", Opt::ForceUnicode => "options.forceUnicodeFont", Opt::JapaneseGlyphs => "options.japaneseGlyphVariants", - // Horizon's own options: English captions (no vanilla keys). - Opt::PadEnabled => "Controller", - Opt::PadVibration => "Vibration", - Opt::PadAdaptiveTriggers => "Adaptive Triggers", - Opt::PadLightbar => "Lightbar", - Opt::PadLookSensitivity => "Look Sensitivity", - Opt::PadInvertX => "Invert Look X", - Opt::PadInvertY => "Invert Look Y", - Opt::PadToggleSneak => "Sneak Button", - Opt::PadMoveDeadzone => "Move Deadzone", - Opt::PadLookDeadzone => "Look Deadzone", - Opt::PadGlyphs => "Button Glyphs", - Opt::PadMenuNav => "Menu Navigation", - Opt::PadKeyboard => "On-Screen Keyboard", + // Horizon's own options: vanilla has no keys for them, so they read + // the namespace the client bundles (assets/horizon/lang). + Opt::PadEnabled => "horizon.options.controller", + Opt::PadVibration => "horizon.options.vibration", + Opt::PadAdaptiveTriggers => "horizon.options.adaptive_triggers", + Opt::PadLightbar => "horizon.options.lightbar", + Opt::PadLookSensitivity => "horizon.options.look_sensitivity", + Opt::PadInvertX => "horizon.options.invert_x", + Opt::PadInvertY => "horizon.options.invert_y", + Opt::PadToggleSneak => "horizon.options.sneak_button", + Opt::PadMoveDeadzone => "horizon.options.move_deadzone", + Opt::PadLookDeadzone => "horizon.options.look_deadzone", + Opt::PadGlyphs => "horizon.options.button_glyphs", + Opt::PadMenuNav => "horizon.options.menu_navigation", + Opt::PadKeyboard => "horizon.options.on_screen_keyboard", } } pub(crate) fn kind(self, s: &Settings) -> Kind { From f28722fb15d8a65f2b2c2c64e6d2c9305e64f1ae Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Sun, 25 Oct 2026 09:34:24 +0100 Subject: [PATCH 2/2] Lang: drop horizon.menu.friends, vanilla has gui.friends.open TitleScreen's Friends button is vanilla's FriendsButton, whose message is gui.friends.open ("Friends" in en_us, translated in every language the prepared resources carry), so Horizon needs no key of its own for it. Bundled now sits after the trait it implements. Co-Authored-By: Claude Opus 5.5 --- .../assets/horizon/lang/en_us.json | 1 - .../assets/horizon/lang/ru_ru.json | 1 - crates/horizon-client/src/lang.rs | 18 ++++++++---------- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/crates/horizon-client/assets/horizon/lang/en_us.json b/crates/horizon-client/assets/horizon/lang/en_us.json index 056162553..de02589e5 100644 --- a/crates/horizon-client/assets/horizon/lang/en_us.json +++ b/crates/horizon-client/assets/horizon/lang/en_us.json @@ -1,5 +1,4 @@ { - "horizon.menu.friends": "Friends", "horizon.options.controller": "Controller", "horizon.options.vibration": "Vibration", "horizon.options.adaptive_triggers": "Adaptive Triggers", diff --git a/crates/horizon-client/assets/horizon/lang/ru_ru.json b/crates/horizon-client/assets/horizon/lang/ru_ru.json index 1152f3669..422fbbc1d 100644 --- a/crates/horizon-client/assets/horizon/lang/ru_ru.json +++ b/crates/horizon-client/assets/horizon/lang/ru_ru.json @@ -1,5 +1,4 @@ { - "horizon.menu.friends": "Друзья", "horizon.options.controller": "Геймпад", "horizon.options.vibration": "Вибрация", "horizon.options.adaptive_triggers": "Адаптивные триггеры", diff --git a/crates/horizon-client/src/lang.rs b/crates/horizon-client/src/lang.rs index f761e1199..94ec4b7ab 100644 --- a/crates/horizon-client/src/lang.rs +++ b/crates/horizon-client/src/lang.rs @@ -29,6 +29,14 @@ pub const DEFAULT: &str = "en_us"; static CURRENT: RwLock>> = RwLock::new(None); +/// A source of resource files: the prepared root plus packs, highest priority last. +pub trait ResourceSource { + fn read(&self, path: &str) -> Option>; + /// The namespaces under `assets/` (resource packs may add their own). + fn namespaces(&self) -> Vec { + vec!["minecraft".into()] + } +} /// Horizon's own strings, compiled in so they need no prepared resources. struct Bundled; impl ResourceSource for Bundled { @@ -44,15 +52,6 @@ impl ResourceSource for Bundled { vec!["horizon".into()] } } - -/// A source of resource files: the prepared root plus packs, highest priority last. -pub trait ResourceSource { - fn read(&self, path: &str) -> Option>; - /// The namespaces under `assets/` (resource packs may add their own). - fn namespaces(&self) -> Vec { - vec!["minecraft".into()] - } -} impl ResourceSource for std::path::PathBuf { fn read(&self, path: &str) -> Option> { std::fs::read(self.join(path)).ok() @@ -234,7 +233,6 @@ mod tests { assert_eq!(en.get("horizon.options.controller"), Some("Controller")); let ru = Language::load(&[&empty], "ru_ru"); assert_eq!(ru.get("horizon.options.controller"), Some("Геймпад")); - assert_eq!(ru.get("horizon.menu.friends"), Some("Друзья")); } #[test]