Fixed Default Language in i18n translation - #58
Conversation
|
Warning Review limit reached
Next review available in: 13 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe JavaScript package adds locale parsing utilities and exports them publicly. The React ChangesLocale language selection
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant LanguageSwitcher
participant LocaleUtilities
participant ConfiguredLanguages
participant BaseLanguageSwitcher
LanguageSwitcher->>LocaleUtilities: normalize current locale and extract base language
LocaleUtilities-->>LanguageSwitcher: return locale values
LanguageSwitcher->>ConfiguredLanguages: resolve exact or base-language match
ConfiguredLanguages-->>LanguageSwitcher: return selected language
LanguageSwitcher->>BaseLanguageSwitcher: provide resolved selection
BaseLanguageSwitcher-->>LanguageSwitcher: apply language change
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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.
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
`@packages/react/src/components/presentation/LanguageSwitcher/LanguageSwitcher.tsx`:
- Around line 122-125: Update handleLanguageChange to compare the selected
language against currentLanguage rather than displayLanguage, ensuring
switchLanguage runs when the displayed fallback differs from the actual locale.
🪄 Autofix
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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: e68216fc-94c0-4944-a48e-6665d33eec36
📒 Files selected for processing (4)
packages/javascript/src/index.tspackages/javascript/src/utils/getBaseLanguage.tspackages/react/src/components/presentation/LanguageSwitcher/LanguageSwitcher.tsxpackages/react/src/contexts/ThunderID/ThunderIDProvider.tsx
17b03f1 to
3b3a1e7
Compare
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 `@packages/javascript/src/utils/normalizeLocaleTag.ts`:
- Around line 35-41: Update normalizeLocaleTag to guarantee consistent
normalization when Intl.Locale is unavailable: either declare an explicit
runtime/browser support requirement in the package metadata, or implement a
deterministic fallback/polyfill path that preserves exact dialect matching. Add
tests covering both the Intl.Locale path and the fallback behavior, including
en-us versus en-US.
🪄 Autofix
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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: e2cd3a76-50e8-46b3-bc8a-72d09edd4eaa
📒 Files selected for processing (3)
packages/javascript/src/index.tspackages/javascript/src/utils/normalizeLocaleTag.tspackages/react/src/components/presentation/LanguageSwitcher/LanguageSwitcher.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/javascript/src/index.ts
- packages/react/src/components/presentation/LanguageSwitcher/LanguageSwitcher.tsx
3b3a1e7 to
f86bb60
Compare
Signed-off-by: Sajid Mannikeri <sajid.mannikeri@ad.infosys.com>
f86bb60 to
5f00abe
Compare
Purpose
LanguageSwitcherpicked the wrong language in two cases:en-USwhen the server only offersen) fell back to whichever language was listed first — which could be Arabic, not English.en-USvs. supporteden-IN), the switcher couldn't tell dialects apart and could highlight the wrong one.Fixes the fallback to consistently prefer English, and makes exact-dialect matches (e.g.
ta-LKvs.ta-IN) take priority over a same-base-language guess.Approach
getBaseLanguage(BCP-47 base language, e.g.en-US→en) andnormalizeLocaleTag(canonical tag form, for exact-dialect comparison) utils in@thunderid/javascript.LanguageSwitcher's auto-fallback effect now compares base languages instead of raw string equality, and explicitly prefers an English entry over the first available language when the current language isn't supported at all.displayLanguage(what's shown as selected) now tries an exact dialect match first, falls back to a base-language match, and only then to the raw code — so a specific dialect isn't silently collapsed to a sibling or to the bare base language when it's actually offered.Related Issues
Related PRs
Checklist
breaking changelabel added.Security checks
Summary by CodeRabbit