Repository navigation
Feat: Add localization support for admin API and quota UI - #9
Conversation
|
Sorry, there are two local commits that haven’t been pushed yet. Could you please rebase again? |
|
The conflict is exactly one hunk in 1.
|
|
@sstreichan — heads up before this merges: the branch currently carries two of While the PR was open I pushed
The awkward part is that a rebase won't drop them: Not blaming you — the commits landing on Generated by AI |
- Implemented localization for error messages in the admin API, allowing responses to be returned in Simplified Chinese based on the Accept-Language header. - Created a new package `i18n` to manage translations and language negotiation. - Added tests to ensure that error messages are correctly localized and that the language negotiation logic functions as expected. - Introduced helper functions to handle request localization and error message formatting.
Completes the master->localization merge for the quota feature (overview sync card, per-account quota rows, refresh-all button), integrated into the i18n version with all quota UI text routed through t(). - Add quota.* i18n keys (duration, kvExceeded, kvLowBalance, kvLastChecked, exceededBadge, lowBalanceBadge, resetAfter, refreshedOne) to en + zh-CN dicts. - Localize quota JS (fmtDuration, quotaResetText, quotaBar, quotaMonthBar, quotaDetail, refreshAccountQuota, refreshAllQuotas, quotaSub). - Fix 4 writeAdminError call sites in admin.go missing *http.Request arg. Build clean; go test ./... passes.
4b41095 to
0c9b10a
Compare
|
Thanks for the detailed review and for testing the merge paths — that saved me a lot of time. The history is fixed and force-pushed; details below. History rebuildThe branch is now a clean linear history of exactly 3 commits on top of current
Your three leak items — all addressed
I also confirmed the 8 unused keys you listed are all gone, and ran a parity audit over the dictionary: 187 en keys / 187 zh-CN keys, perfect parity, every Two small things (non-blocking)
Ready for another look whenever you have time. |
This pull request updates error handling in the
internal/app/admin.gofile to provide localized error messages based on the caller'sAccept-Languageheader. The main change is the introduction of thei18n.Messagefunction to translate error messages, and the refactoring of error response functions to support localization throughout the admin API.The most important changes are:
Localization of Error Responses:
i18n.Messagefunction to provide localized error messages, falling back to English if the requested language is not supported. This improves user experience for non-English speakers.Refactoring of Error Handling:
writeAdminErrorfunction signature is changed to accept the*http.Requestobject, allowing it to determine the appropriate language for the error message. All calls towriteAdminErrorthroughout the file are updated accordingly. [[1]]Consistent Error Localization in OAuth Flow:
i18n.Message, ensuring that all user-facing errors in the OAuth flow are localized as well.These changes collectively ensure that all admin API error messages are ready for localization, improving accessibility and user experience for international users.