feat: add client-side dynamic i18n support to usage dashboard#2
Open
htqxd wants to merge 1 commit into
Open
Conversation
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.
Summary
Integrates client-side dynamic internationalization (i18n) for the single-page dashboard (
DASHBOARD_HTMLinusage_dashboard.py), supporting Chinese (default), Vietnamese, and English.Key enhancements:
application.
load()function with the translation helpert(). This prevents the 30-second periodic database refresh loop fromreverting translated tables back to Chinese.
separators) using
Intl.NumberFormataccording to the active locale.opacity: 0) at initialization and restores visibility only after i18n processing is complete, preventingvisual flashes of the default language.
localStorage. Wrapped storage access in atry-catchblock and implemented language validation (ALLOWED_LANGS) to preventfrontend crashes in restrictive environments (e.g., private browsing, iframes).
Test plan
python3 usage_dashboard.py serve
- Verify that the page auto-detects your browser language on the initial load.
- Change the language using the toolbar selector to Vietnamese, English, and Chinese. Confirm that static headers, KPIs, and table columns translate immediately.
- Check the horizontal model consumption chart to confirm that the fallback label translates correctly (no English 'unknown' leak).
- Wait 30 seconds or click "Refresh" to verify that newly loaded table rows do not revert to Chinese.
- Reload the page (F5) to verify that your selected language persists via localStorage.