-
Notifications
You must be signed in to change notification settings - Fork 998
fix: translate unit names in event panel messages #3242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
d424caf
b50d845
ce4b19f
70fa419
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -383,7 +383,13 @@ export class EventsDisplay extends LitElement implements Layer { | |
|
|
||
| let description: string = event.message; | ||
| if (event.message.startsWith("events_display.")) { | ||
| description = translateText(event.message, event.params ?? {}); | ||
| const params = { ...(event.params ?? {}) }; | ||
| if (typeof params.unit === "string") { | ||
| const unitKey = | ||
| "unit_type." + params.unit.toLowerCase().replace(/ /g, "_"); | ||
| params.unit = translateText(unitKey); | ||
| } | ||
|
Comment on lines
+393
to
+403
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe this should go in translateText() instead? that way we'll automatically translate units if we render unit names somewhere else in the UI.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @evanpelle would strongly advice against that, because what if a player is named "Factory"? There are keys with params carrying player names. Which would then suddenly be translated because the player name so happens to be the same as the unit name in English. Not entirely inconceivable. I would also advice against the above code in this PR. Because he current solution in the code above has the same issue, it would translate a player name like "Factory" which it should not do. That is why i proposed (in comment above) to send the key to |
||
| description = translateText(event.message, params); | ||
| } | ||
|
|
||
| this.addEvent({ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.