[PR #5106] [MERGED] Localization: the merchant screen follows the language, Horizon's strings in Chinese #6078

Closed
opened 2026-11-03 06:11:27 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5106
Author: @masa-masa-0314
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @rdbtCVS

Base: main ← Head: fix/ui-localization


📝 Commits (2)

  • 5876fa5 Localization: the merchant screen follows the language, and Horizon's own strings come in Chinese
  • 9a1dc67 Localization: the server connection's phases follow the language

📊 Changes

11 files changed (+261 additions, -24 deletions)

View changed files

📝 crates/horizon-client-core/src/lang.rs (+13 -0)
📝 crates/horizon-client/assets/horizon/lang/en_us.json (+4 -1)
📝 crates/horizon-client/assets/horizon/lang/es_es.json (+4 -1)
📝 crates/horizon-client/assets/horizon/lang/pl_pl.json (+4 -1)
📝 crates/horizon-client/assets/horizon/lang/ru_ru.json (+4 -1)
📝 crates/horizon-client/assets/horizon/lang/uk_ua.json (+4 -1)
➕ crates/horizon-client/assets/horizon/lang/zh_cn.json (+203 -0)
📝 crates/horizon-client/src/game.rs (+9 -3)
📝 crates/horizon-client/src/game/remote.rs (+6 -2)
📝 crates/horizon-client/src/game/trading.rs (+5 -9)
📝 crates/horizon-client/src/net.rs (+5 -5)

📄 Description

🤖 Opened by masa-masa-0314's AI agent (ZCode/GLM), not by masa-masa-0314 personally.

What and why

Three fixes for text the language screen could not translate:

  • The merchant (villager trading) screen stayed English in every non-English language. Its title, the villager profession, the trade level ("Novice".."Master"), the Trades caption, the inventory caption and the out-of-stock hint were drawn through Enchantments::translate — a pinned en_us map loaded once at startup — instead of the selected language. They go through lang::get_or now, like the rest of the menus.
  • The reconfiguring screen's disconnect button showed the raw key gui.disconnect. No language file has that key (vanilla's button is CommonComponents.GUI_DISCONNECT = menu.disconnect, confirmed by decompiling CommonComponents from the 26.3 jar). It is menu.disconnect now.
  • Horizon's own strings had no zh_cn bundle: the settings, graphics, HDR, controller, extras, shader packs, mods and AI agent pages, and the multiplayer invite dialog, were English for a Chinese player. A complete zh_cn bundle ships now (198 keys; ru_ru, pl_pl, uk_ua, es_es already exist and Language::load picks the file up through the same source scan — nothing else needs wiring).

Audit of the rest of the game

I extracted every key a lang call passes and diffed them against vanilla's en_us/zh_cn and Horizon's bundles:

  • Every key resolves now; vanilla-namespace keys all have zh_cn values; no production text draw keeps a hardcoded English literal.
  • test_instance_block.invalid_test looks like a missing key but is vanilla's own (TestInstanceBlockEntity translates it without the key existing in any language file — decompiled from 26.3), so it stays.
  • Horizon-only command feedback (/raid, /profiler, the agent's messages — ~170 Text::literal sites) still speaks literal English by house style; localizing those would need new keys across all six bundles and is left alone here.
  • ru_ru misses one key (horizon.mods.not_built) and pl/uk/es carry 13 keys each — partial bundles are fine (Language::load always merges the en_us layer under the selected language), but worth knowing.

Vanilla reference

  • CommonComponents.GUI_DISCONNECT = menu.disconnect (net/minecraft/network/chat/CommonComponents, decompiled from the 26.3 jar).
  • MerchantScreen's texts (merchant.title, merchant.level.*, merchant.trades, merchant.deprecated, container.inventory, entity.minecraft.villager.*) — vanilla keys, all present in zh_cn.json.

Self-check

**pr_ready** (`tools/pr_ready.py --base upstream/main`)

| Check | Result |
| --- | --- |
| Scope | ✅ 4 files, +220 −10 |
| Cargo.lock | ✅ unchanged |
| Public tree | ✅ |
| rustfmt | ✅ |
| clippy | ✅ |
| tests: horizon-client, horizon-client-core | ✅ 1386 passed |
| doc tests | ✅ |

pr_ready's Python suite reports test_report_without_a_load_average (Windows cmd /C ver output decoding on this machine's codepage); it fails identically on a pristine upstream checkout and touches nothing this PR changes.

Screenshots

No screenshot: this machine's offscreen renderer is blank (project known issue). The change is text-only and best checked live: switch the language to 简体中文 and open a villager's trade screen, the Horizon settings pages, and the reconfiguring screen.

Follow-up (server connection screen)

The connect flow's phase texts were literals on the net thread: "Connecting to the server..." (also the session's initial status), "Joining world..." and "Finding your friend's world..." stayed English while the middle phases were already keys. They now use connect.connecting, connect.joining (vanilla, zh_cn present) and a new horizon.multiplayer.finding_friend added to all six bundles, and the local world-open progress line uses new horizon.loading.opening_world / horizon.loading.cancelling_world keys instead of hardcoded "Opening world" / "Cancelling world".

NOT_SIGNED_IN deliberately stays English: reconnect::allowed classifies disconnect reasons by English keywords ("online mode", "microsoft account"), so a translated message would slip past the never-retry list — that matcher needs to work on keys rather than texts, which is its own fix.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/5106 **Author:** [@masa-masa-0314](https://github.com/masa-masa-0314) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `fix/ui-localization` --- ### 📝 Commits (2) - [`5876fa5`](https://github.com/horizon-rust/horizon/commit/5876fa5ff8c99cf5ea9363c1a18d8051b059ccc1) Localization: the merchant screen follows the language, and Horizon's own strings come in Chinese - [`9a1dc67`](https://github.com/horizon-rust/horizon/commit/9a1dc67c0d55d67410a5b1e0fc55e355d42d5db5) Localization: the server connection's phases follow the language ### 📊 Changes **11 files changed** (+261 additions, -24 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-core/src/lang.rs` (+13 -0) 📝 `crates/horizon-client/assets/horizon/lang/en_us.json` (+4 -1) 📝 `crates/horizon-client/assets/horizon/lang/es_es.json` (+4 -1) 📝 `crates/horizon-client/assets/horizon/lang/pl_pl.json` (+4 -1) 📝 `crates/horizon-client/assets/horizon/lang/ru_ru.json` (+4 -1) 📝 `crates/horizon-client/assets/horizon/lang/uk_ua.json` (+4 -1) ➕ `crates/horizon-client/assets/horizon/lang/zh_cn.json` (+203 -0) 📝 `crates/horizon-client/src/game.rs` (+9 -3) 📝 `crates/horizon-client/src/game/remote.rs` (+6 -2) 📝 `crates/horizon-client/src/game/trading.rs` (+5 -9) 📝 `crates/horizon-client/src/net.rs` (+5 -5) </details> ### 📄 Description > 🤖 Opened by masa-masa-0314's AI agent (ZCode/GLM), not by masa-masa-0314 personally. ## What and why Three fixes for text the language screen could not translate: - **The merchant (villager trading) screen stayed English in every non-English language.** Its title, the villager profession, the trade level ("Novice".."Master"), the Trades caption, the inventory caption and the out-of-stock hint were drawn through `Enchantments::translate` — a pinned en_us map loaded once at startup — instead of the selected language. They go through `lang::get_or` now, like the rest of the menus. - **The reconfiguring screen's disconnect button showed the raw key `gui.disconnect`.** No language file has that key (vanilla's button is `CommonComponents.GUI_DISCONNECT` = `menu.disconnect`, confirmed by decompiling `CommonComponents` from the 26.3 jar). It is `menu.disconnect` now. - **Horizon's own strings had no zh_cn bundle**: the settings, graphics, HDR, controller, extras, shader packs, mods and AI agent pages, and the multiplayer invite dialog, were English for a Chinese player. A complete zh_cn bundle ships now (198 keys; ru_ru, pl_pl, uk_ua, es_es already exist and `Language::load` picks the file up through the same source scan — nothing else needs wiring). ## Audit of the rest of the game I extracted every key a `lang` call passes and diffed them against vanilla's `en_us`/`zh_cn` and Horizon's bundles: - Every key resolves now; vanilla-namespace keys all have zh_cn values; no production text draw keeps a hardcoded English literal. - `test_instance_block.invalid_test` looks like a missing key but is vanilla's own (`TestInstanceBlockEntity` translates it without the key existing in any language file — decompiled from 26.3), so it stays. - Horizon-only command feedback (`/raid`, `/profiler`, the agent's messages — ~170 `Text::literal` sites) still speaks literal English by house style; localizing those would need new keys across all six bundles and is left alone here. - ru_ru misses one key (`horizon.mods.not_built`) and pl/uk/es carry 13 keys each — partial bundles are fine (`Language::load` always merges the en_us layer under the selected language), but worth knowing. ## Vanilla reference - `CommonComponents.GUI_DISCONNECT` = `menu.disconnect` (`net/minecraft/network/chat/CommonComponents`, decompiled from the 26.3 jar). - `MerchantScreen`'s texts (`merchant.title`, `merchant.level.*`, `merchant.trades`, `merchant.deprecated`, `container.inventory`, `entity.minecraft.villager.*`) — vanilla keys, all present in `zh_cn.json`. ## Self-check ``` **pr_ready** (`tools/pr_ready.py --base upstream/main`) | Check | Result | | --- | --- | | Scope | ✅ 4 files, +220 −10 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | rustfmt | ✅ | | clippy | ✅ | | tests: horizon-client, horizon-client-core | ✅ 1386 passed | | doc tests | ✅ | ``` `pr_ready`'s Python suite reports `test_report_without_a_load_average` (Windows `cmd /C ver` output decoding on this machine's codepage); it fails identically on a pristine upstream checkout and touches nothing this PR changes. ## Screenshots No screenshot: this machine's offscreen renderer is blank (project known issue). The change is text-only and best checked live: switch the language to 简体中文 and open a villager's trade screen, the Horizon settings pages, and the reconfiguring screen. ### Follow-up (server connection screen) The connect flow's phase texts were literals on the net thread: **"Connecting to the server..."** (also the session's initial status), **"Joining world..."** and **"Finding your friend's world..."** stayed English while the middle phases were already keys. They now use `connect.connecting`, `connect.joining` (vanilla, zh_cn present) and a new `horizon.multiplayer.finding_friend` added to all six bundles, and the local world-open progress line uses new `horizon.loading.opening_world` / `horizon.loading.cancelling_world` keys instead of hardcoded "Opening world" / "Cancelling world". `NOT_SIGNED_IN` deliberately stays English: `reconnect::allowed` classifies disconnect reasons by English keywords ("online mode", "microsoft account"), so a translated message would slip past the never-retry list — that matcher needs to work on keys rather than texts, which is its own fix. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:11:27 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#6078
No description provided.