Skip to content

fix(lobbyswitcher): translate the switcher texts - #412

Merged
TheMeinerLP merged 1 commit into
mainfrom
fix/lobbyswitcher-translations
Oct 10, 2026
Merged

TheMeinerLP merged 1 commit into
mainfrom
fix/lobbyswitcher-translations

Conversation

@TheMeinerLP

Copy link
Copy Markdown
Contributor

Root cause

The lobby switcher's hotbar clock was built once, when the LobbyItem bean was created, with messages.itemName(Locale.ENGLISH). That call renders the translatable component immediately through GlobalTranslator. If the bundle is not yet registered at that point, the render leaves the translatable component untouched, and the name sent to the client is the raw key titan.lobbyswitcher.item.name. Even when it was registered in time, the stored stack was English for every player, because the hotbar equips the same ItemStack instance for everyone.

The reproduction is a clock built before registration, then handed to a German player. Before the fix its name is empty when rendered to plain text (the client shows the raw key), and the German player does not get Lobbys.

The inventory, entry texts and chat messages were already rendered per locale and are covered by existing tests (e.g. SwitcherInventoryTest German viewer). The bundle keys are present in both messages_en.properties and messages_de.properties, and the bundle is registered with GlobalTranslator before the inventory opens.

Fix

  • core: LobbyItem gets a localized function (Locale -> ItemStack). The existing 5-argument constructor keeps the stack identical for every player. stackFor(Locale) returns the stack for a locale.
  • hotbar: HotbarLobbyItems.equip builds the placements for the player's locale (English when the client has not reported one). The stamped identity tag is applied to localized stacks too, so dispatch keeps working.
  • lobbyswitcher: the clock bean no longer renders a name at build time. Its localized function renders titan.lobbyswitcher.item.name for the player's locale at equip time.
  • lobbyswitcher: LobbySwitcherMessages.render treats a null locale as English. Players whose client has not sent a locale no longer cause an NPE in the unavailable and click messages.

Texts checked (all keys exist in messages_en and messages_de):

key en de
item.name (clock) Lobbies Lobbys
title Lobbies Lobbys
entry.count Players: x/y - click to join Spieler: x/y - Klicken zum Beitreten
state.current You are here (x/y) Du bist hier (x/y)
state.full Full (x/y) Voll (x/y)
state.not_ready Not ready yet Noch nicht bereit
state.unavailable Lobbies are not available right now Lobbys sind gerade nicht verfügbar
message.sent / current / full / not_ready / gone / unavailable see bundle see bundle

Tests

  • LobbySwitcherItemsTest
    • clockBuiltBeforeRegistrationIsNamedWhenGiven: reproduces the live symptom (raw key or empty name) and asserts the German name and non-italic decoration after equip.
    • clockNameFollowsThePlayersLocale: German player sees Lobbys, English player sees Lobbies.
  • HotbarLobbyItemsIntegrationTest.equipGivesTheStackOfThePlayersLocale: a localized item gives the German player the German stack.
  • LobbySwitcherMessagesBundleTest (existing) checks that every key used by the module exists in both bundles and that the German bundle has the same keys as English.

All tests are Minestom Env based with env.tick() where ticks are needed, no sleeps and no system time.

https://claude.ai/code/session_01GXose9rakuRNZoM3TP3xj1

The clock's name was rendered once at bean build with an English locale,
before the bundle was registered, so players saw the raw key. Lobby items
can now render a stack per locale, and the hotbar equips each player with
the stack for their locale. A missing client locale falls back to English.

Claude-Session: https://claude.ai/code/session_01GXose9rakuRNZoM3TP3xj1
@TheMeinerLP
TheMeinerLP requested a review from a team as a code owner October 10, 2026 23:03
@TheMeinerLP
TheMeinerLP merged commit f47002c into main Oct 10, 2026
6 checks passed
@TheMeinerLP
TheMeinerLP deleted the fix/lobbyswitcher-translations branch October 10, 2026 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant