fix: weather localization for locale variants like zh_CN#348
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds a helper normalizeLang(lang) that derives a base language (e.g., zh from zh_CN) and applies it in getOpenMeteoLang() and getWeatherLabel() so locale variants are recognized for weather localization. ChangesLanguage Normalization for Weather Localization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 `@src/features/weather.js`:
- Around line 9-12: normalizeLang currently only splits on '_' so hyphenated
locales like "zh-CN" won't normalize; update the normalizeLang function to split
on both '_' and '-' (e.g., split on a regex or replace both separators) and
return the base language in a consistent case (lowercase), also guard against
falsy input so it doesn't throw on undefined/null.
🪄 Autofix (Beta)
❌ Autofix failed (check again to retry)
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: 4603f076-f862-4b60-8299-11431358a608
📒 Files selected for processing (1)
src/features/weather.js
|
@coderabbitai full review |
✅ Action performedFull review finished. |
Summary
The weather widget ignored Chinese, Portuguese, and English locale variants (e.g.
zh_CN,pt_BR,en_US) becausegetWeatherLabel()andgetOpenMeteoLang()compared the full locale string against base language codes. Users on those locales always saw English weather labels and English geocoding results.What Changed
normalizeLang()helper insrc/features/weather.jsthat strips the country suffix from locale variants ("zh_CN"→"zh")getOpenMeteoLang()so geocoding requests use the correct API language code for variant localesgetWeatherLabel()so weather condition labels resolve to the correctlabel*key inWEATHER_CODESVerification
npm run lint— cleannpm test— 431/431 tests passingNotes
pt_BRanden_USsrc/features/weather.jsSummary by CodeRabbit