Repository navigation
feat: update autologin translation - #10
Conversation
📝 WalkthroughWalkthroughThe PR adds URL-based language parameter support to the context provider and supplies auto-login UI translations for English and French. The context now reads the ChangesAuto-login Language Selection
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. 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
🧹 Nitpick comments (1)
src/langs/fr.json (1)
35-41: 💤 Low valueAll translation keys are correctly added.
All seven
AUTO_LOGIN_*keys match the English version. However, there's a minor punctuation inconsistency:AUTO_LOGIN_WELCOME_TITLEin French (line 39) has an exclamation mark "Bienvenue !" while the English version (en.json line 54) was changed to "Welcome" without an exclamation mark.Consider aligning the punctuation style between languages for consistency.
✨ Suggested alignment for consistent tone
- "AUTO_LOGIN_WELCOME_TITLE": "Bienvenue !", + "AUTO_LOGIN_WELCOME_TITLE": "Bienvenue",🤖 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 `@src/langs/fr.json` around lines 35 - 41, The French translation for AUTO_LOGIN_WELCOME_TITLE uses an exclamation mark ("Bienvenue !") which is inconsistent with the English key (en.json) now set to "Welcome" without punctuation; update the AUTO_LOGIN_WELCOME_TITLE value to "Bienvenue" (remove the trailing "!") so the punctuation/tone matches across languages, keeping the other AUTO_LOGIN_* keys unchanged.
🤖 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 `@src/contexts/CurrentMemberContext.tsx`:
- Around line 30-33: The lang assignment allows an Individual account to yield
undefined and be passed to i18n.changeLanguage; update the computation of lang
(the variable set from query.data?.type, AccountType.Individual,
query.data?.extra?.lang, search.get('lang'), DEFAULT_LANG) so it uses a proper
fallback chain: use query.data?.extra?.lang if truthy, otherwise fall back to
search.get('lang') (if present), otherwise DEFAULT_LANG—e.g. replace the ternary
branch for AccountType.Individual with a nullish/coalescing check that
guarantees a non-undefined string before calling i18n.changeLanguage.
---
Nitpick comments:
In `@src/langs/fr.json`:
- Around line 35-41: The French translation for AUTO_LOGIN_WELCOME_TITLE uses an
exclamation mark ("Bienvenue !") which is inconsistent with the English key
(en.json) now set to "Welcome" without punctuation; update the
AUTO_LOGIN_WELCOME_TITLE value to "Bienvenue" (remove the trailing "!") so the
punctuation/tone matches across languages, keeping the other AUTO_LOGIN_* keys
unchanged.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: cd2732a2-ccde-407e-bc6a-a3787dd46247
📒 Files selected for processing (3)
src/contexts/CurrentMemberContext.tsxsrc/langs/en.jsonsrc/langs/fr.json
| const lang = | ||
| query.data && query.data?.type === AccountType.Individual | ||
| query.data?.type === AccountType.Individual | ||
| ? query.data?.extra?.lang | ||
| : DEFAULT_LANG; | ||
| : (search.get('lang') ?? DEFAULT_LANG); |
There was a problem hiding this comment.
Individual accounts without a language preference will set lang to undefined.
When query.data?.type === AccountType.Individual is true but query.data?.extra?.lang is undefined or null, the lang variable becomes undefined instead of falling back to the URL parameter or DEFAULT_LANG. This causes i18n.changeLanguage(undefined) to be called at line 36, which is incorrect.
The fallback chain should be: Individual account language preference → URL lang parameter → DEFAULT_LANG.
🔧 Proposed fix to ensure proper fallback chain
// update language depending on user setting
const lang =
- query.data?.type === AccountType.Individual
- ? query.data?.extra?.lang
- : (search.get('lang') ?? DEFAULT_LANG);
+ query.data?.type === AccountType.Individual
+ ? (query.data?.extra?.lang ?? search.get('lang') ?? DEFAULT_LANG)
+ : (search.get('lang') ?? DEFAULT_LANG);📝 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 lang = | |
| query.data && query.data?.type === AccountType.Individual | |
| query.data?.type === AccountType.Individual | |
| ? query.data?.extra?.lang | |
| : DEFAULT_LANG; | |
| : (search.get('lang') ?? DEFAULT_LANG); | |
| // update language depending on user setting | |
| const lang = | |
| query.data?.type === AccountType.Individual | |
| ? (query.data?.extra?.lang ?? search.get('lang') ?? DEFAULT_LANG) | |
| : (search.get('lang') ?? DEFAULT_LANG); |
🤖 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 `@src/contexts/CurrentMemberContext.tsx` around lines 30 - 33, The lang
assignment allows an Individual account to yield undefined and be passed to
i18n.changeLanguage; update the computation of lang (the variable set from
query.data?.type, AccountType.Individual, query.data?.extra?.lang,
search.get('lang'), DEFAULT_LANG) so it uses a proper fallback chain: use
query.data?.extra?.lang if truthy, otherwise fall back to search.get('lang') (if
present), otherwise DEFAULT_LANG—e.g. replace the ternary branch for
AccountType.Individual with a nullish/coalescing check that guarantees a
non-undefined string before calling i18n.changeLanguage.
Summary by CodeRabbit
New Features
Localization