fix(i18n): fallback to server locale for "Default" user lang in notifs#3190
Conversation
`getIntl` used `??` which doesn't catch empty string which is the value stored when a user sets their display language to "Default". Falsy locales now resolve to the server's main locale before en. fix #3151
📝 WalkthroughWalkthrough
Server i18n locale default
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR fixes notification localization when a user’s display language is set to “Default” (stored as an empty string), by falling back to the server’s configured application language and then to English.
Changes:
- Update server-side
getIntllocale resolution to treat falsy/empty user locale as “use server locale”. - Ensure agent-provided locales also fall back to English if an unexpected empty value is encountered.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@server/i18n/index.ts`:
- Around line 42-45: The issue is that getSettings().main.locale is being cast
to AvailableLocale without validation, and the MainSettings interface declares
locale as a plain string instead of constraining it to valid locale values. To
fix this, update the MainSettings interface to declare the locale property as
type AvailableLocale instead of string, ensuring type safety at compile time.
Additionally, add validation logic at the points where locale values are
assigned (such as API endpoints or settings forms) to verify that only valid
AvailableLocale values are stored in the settings, preventing invalid data from
being persisted in the first place.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1f15d04a-23e6-4b5f-b848-68b45a678f36
📒 Files selected for processing (1)
server/i18n/index.ts
Description
When a user's display language is set to "Default", their stored locale is
an empty string, ignoring the server's configured application language.
Affects all per-user agents (email, Telegram, Pushbullet, Pushover,
webpush, Discord with
useUserLocale: true). Channel agents (Slack,Gotify, ntfy, Discord with
useUserLocale: false) pass an explicit localeand are unaffected, though they now also correctly fall back to the server
default if their configured locale is somehow empty.
How Has This Been Tested?
(no need)
Screenshots / Logs (if applicable)
Checklist:
pnpm buildpnpm i18n:extractSummary by CodeRabbit