Fixed Default Language in i18n translation - #58
Conversation
Signed-off-by: Sajid Mannikeri <sajid.mannikeri@ad.infosys.com>
📝 WalkthroughWalkthroughThe PR adds and exports ChangesLocale language selection
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant LanguageSwitcher
participant getBaseLanguage
participant ConfiguredLanguages
LanguageSwitcher->>getBaseLanguage: Resolve detected locale
getBaseLanguage-->>LanguageSwitcher: Return base language
LanguageSwitcher->>ConfiguredLanguages: Find matching configured option
ConfiguredLanguages-->>LanguageSwitcher: Return matching or fallback option
LanguageSwitcher->>ConfiguredLanguages: Apply selected option on change
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
packages/javascript/src/index.tsESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox. packages/javascript/src/utils/getBaseLanguage.tsESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox. packages/react/src/components/presentation/LanguageSwitcher/LanguageSwitcher.tsxESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.
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
| const handleLanguageChange = (language: string): void => { | ||
| if (language !== currentLanguage) { | ||
| if (language !== displayLanguage) { | ||
| switchLanguage(language); | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Compare the selected locale with currentLanguage.
At Line 123, displayLanguage can differ from currentLanguage. For example, with configured locales en-US and en-GB, a current locale of en-AU displays en-US. When the user selects en-US, this condition prevents switchLanguage, so the concrete locale remains en-AU.
Proposed fix
const handleLanguageChange = (language: string): void => {
- if (language !== displayLanguage) {
+ if (language !== currentLanguage) {
switchLanguage(language);
}
};📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const handleLanguageChange = (language: string): void => { | |
| if (language !== currentLanguage) { | |
| if (language !== displayLanguage) { | |
| switchLanguage(language); | |
| } | |
| const handleLanguageChange = (language: string): void => { | |
| if (language !== currentLanguage) { | |
| switchLanguage(language); | |
| } | |
| }; |
🤖 Prompt for 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.
In
`@packages/react/src/components/presentation/LanguageSwitcher/LanguageSwitcher.tsx`
around lines 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.
Purpose
Approach
Related Issues
Related PRs
Checklist
breaking changelabel added.Security checks
Summary by CodeRabbit
New Features
en-USwith English.Bug Fixes