-
Notifications
You must be signed in to change notification settings - Fork 38
[i18n] Full i18n Support #41
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
Conversation
|
The NaN / 0 is a WoWhead issue, can replicate it on their site as well. |
|
@dodoels can you update your branch from current master |
|
@1337LutZ please review when you get chance, thanks! |
I think there were some more changes made that you are missing and need to merge in. The test is failing on a Frontend warnign that has been resolved. Sorry! |
|
@1337LutZ can you send the page that you tested with on wowhead? Trying to pass it along to their devs |
[i18n] Full i18n Support: restructure and some redesign, and more examples on the UI
Updated the branch with the latest changes. This should now be a good MVP to be included in the release. |
| } | ||
| }, | ||
| "common": { | ||
| "phases": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If phases are just going to be a number then we actually dont need this right? We can just use the browser's Int.NumberFormat. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat.
If we use this entry I would suggest that we actually have this for example:
"1": "Phase 1 (T14)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh that's where you use it. We also use it in the Filter dropdown (I thought that's where you wanted this).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which filter are you referring? xD
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Phases filter in the Gear picker popup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, that will be later, I am doing BFS now and making sure all first level UI are localized
| const statName = unitStat.getShortName(player.getClass()); | ||
| let statName: string; | ||
| if (unitStat.isStat()) { | ||
| statName = translateStat(unitStat.getStat()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason that we don't translate the stat names directly? We have getFullName and getShortName so this should already be possible. We can then get the translation in these functions.
Both of these use: getStatName and getClassPseudoStatName, so moving the stat translations to over there should resolve any manual interaction needed here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getStatName and getClassPseudoStatName returns the enums generated from protobuf which is a more rebust solution.
Stat.StatStrength <-- get the stat enum
[Stat.StatStrength]: 'strength' <-- find the translation key
en[common.stat.strength] <-- find the actual translated text
if we go with direct translation from the short names..
Spell Crit <-- spell name in string
spell_crit <-- parse into translation key
en[common.stat.spell_crit] <-- find the actual translated text
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be specific, enums to string is more robust than string to parsed string to string which requires more manual works
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I mean move the translateStat into the getFullName and getShortName. That way when you use those 2 functions, it's always localized and the translateStat is contained to only there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved, but not sure if this is still revelant
// Not sure if this is needed anymore, but keeping it for now
if (playerClass == Class.ClassHunter) {
return fullName.replace('Physical', 'Ranged');
} else {
return fullName.replace('Physical', 'Melee');
}
I left it as it is for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is still relevant! :D Hunter still has Ranger AP specific buffs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved in e7f267c
ui/i18n/localization.ts
Outdated
| window.location.reload(); | ||
| }; | ||
| li.appendChild(a); | ||
| dropdownMenu.appendChild(li); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you change this to a localization.tsx file, we can nicely use JSX to build this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some functions in localization.ts are being imported into index.html, let me try if jsx can be resolved in the build
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know, but we can still write this in a JSX syntax and append it to the DOM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved
1337LutZ
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments!
|
@1337LutZ Addressed all your comments. Please checkout the branch and play with it see if any further issue. I will be afk until August, if this is not mergeble I will have to come back later - Otherwise, please feel free to merge it! |
fix windows query import


🌍 Full i18n Support
Summary
This PR introduces full internationalization (i18n) support, with French (FR) added as a second-language example. The i18n implementation is fully integrated with the current UI and production-ready.
1. 🧱 Introducing the i18n Framework
Following the design proposed earlier, this PR completes the green-box portion in the diagram — enabling robust i18n support for the UI.
What’s included:
/ui/i18n/, which contains all configuration and utility functions for i18n./assets/locale/using a standardized JSON format, which can be reused by the Golang backend./docs/. The mainREADME.mdhas been simplified and now links to the relevant sections.2. 🌐 What’s Been Localized
index.html) and simulator/spec page (index_template.html).This implementation serves as a working example to guide future localization work.
3. 🧩 Design Considerations
🗂️ Locale JSON Structure
Localization files are modularized by UI section to improve clarity and maintainability:
Benefit: Clear structure for contributors to locate and manage translations efficiently.
🔁 Enum Mapping & Safe Translations
Many internal enums like
StrengthorAgilityare used as UI text, keys, and logic values. Direct translation could break core functionality.Solution:
entity_mapping.ts: Maps raw Go-enum values to stable English keys.translation.ts: Maps those keys to localized strings from the locale files.This separation ensures translation logic is safe, extensible, and won’t interfere with the sim's logic or state management.