Repository navigation
fix(lobbyswitcher): translate the switcher texts - #412
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
The lobby switcher's hotbar clock was built once, when the
LobbyItembean was created, withmessages.itemName(Locale.ENGLISH). That call renders the translatable component immediately throughGlobalTranslator. 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 keytitan.lobbyswitcher.item.name. Even when it was registered in time, the stored stack was English for every player, because the hotbar equips the sameItemStackinstance 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.
SwitcherInventoryTestGerman viewer). The bundle keys are present in bothmessages_en.propertiesandmessages_de.properties, and the bundle is registered withGlobalTranslatorbefore the inventory opens.Fix
core:LobbyItemgets alocalizedfunction (Locale -> ItemStack). The existing 5-argument constructor keeps the stack identical for every player.stackFor(Locale)returns the stack for a locale.hotbar:HotbarLobbyItems.equipbuilds 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. Itslocalizedfunction renderstitan.lobbyswitcher.item.namefor the player's locale at equip time.lobbyswitcher:LobbySwitcherMessages.rendertreats 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_enandmessages_de):Tests
LobbySwitcherItemsTestclockBuiltBeforeRegistrationIsNamedWhenGiven: reproduces the live symptom (raw key or empty name) and asserts the German name and non-italic decoration after equip.clockNameFollowsThePlayersLocale: German player seesLobbys, English player seesLobbies.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
Envbased withenv.tick()where ticks are needed, no sleeps and no system time.https://claude.ai/code/session_01GXose9rakuRNZoM3TP3xj1