feat(countries): localize country display names using active UI locale - #435
Merged
Conversation
Greptile SummaryThe PR localizes country names according to the active UI locale while retaining canonical ISO codes.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| frontend/src/lib/countries.ts | Adds localized country-name resolution, multi-field search, and locale-aware sorting without an accepted correctness issue. |
| frontend/src/app/setup/page.tsx | Uses the localization helpers for the country picker and fully removes the previously reported redundant query normalization. |
| frontend/src/app/(dashboard)/settings/page.tsx | Displays and orders Settings country options using the active UI locale without an accepted correctness issue. |
| tests/country-localization.test.ts | Adds behavioral coverage for localized names, search fields, fallback behavior, and sorting. |
| package.json | Registers the focused country-localization test in the repository test commands. |
Reviews (3): Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." | Re-trigger Greptile
…zed-country-names # Conflicts: # package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Localize country names in the Setup and Settings selectors to the active UI locale using native Intl.DisplayNames, while keeping ISO country codes canonical, supporting localized sorting and search, and remaining fully offline without translation catalog bloat.
What Changed
getLocalizedCountryName,countryMatchesQuery, andsortCountriesByLocalizedNamehelpers infrontend/src/lib/countries.tsthat useIntl.DisplayNamesto resolve country names in the active UI locale, with cache and English fallback.test:country-localizationscript and a new test file covering localized name resolution, multi-field search, and locale-aware sorting.Risk Assessment
✅ Low: Change is well-bounded: new utility functions in countries.ts, two consumer pages updated, one test added. All assertions are behavioral. No security, error handling, or correctness issues found.
Testing
Ran the dedicated country-localization test, the run-test.sh wrapper, both frontend and backend builds, and a manual behavioral script that exercised localized name resolution (Intl.DisplayNames), multi-locale search matching (localized + English fallback + ISO code + currency + locale), localized sorting with pinned countries, and edge cases — all passed with no issues.
Evidence: Country localization test output
Evidence: Manual behavioral evidence across 4 locales
Evidence: Evidence file
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
🔧 **Rebase** - 2 issues found → auto-fixed ✅
frontend/src/app/setup/page.tsx- merge conflict rebasing onto origin/mainpackage.json- merge conflict rebasing onto origin/main🔧 Fix applied.
✅ Re-checked - no issues remain.
package.json:36- test:issue-389-timezone-override was accidentally dropped from thetestscript. The old test script ended with...&& bash tests/run-test.sh npm run test:startup-cache && bash tests/run-test.sh npm run test:issue-389-timezone-override, but the new one ends attest:startup-cache. Thetest:country-localizationtest was added (after test:phone) buttest:issue-389-timezone-overridewas simultaneously removed from the tail, keeping the total count at 99. The script definition still exists and should be restored to the test chain.frontend/src/app/(dashboard)/settings/page.tsx:263-sortCountriesByLocalizedName(COUNTRIES, locale)is called on every render withoutuseMemo. SinceCOUNTRIESis static andlocalechanges rarely, this recomputes a sorted copy of ~100 countries (withIntl.DisplayNames.of()calls per comparison) on every render. Consider wrapping inuseMemowith[locale]dependency. Same applies to setup page line 157.🔧 Fix: Restore test:issue-389-timezone-override to end of test chain in package.json
1 info still open:
tests/country-localization.test.ts:68- The pt-BR sort test (lines 68-72) uses the same 5-country subset as the Spanish test (lines 63-67) and produces the identical expected order ['IN', 'AR', 'DE', 'US', 'JP']. It exercises a different locale argument but does not verify a different sorting outcome or a different code path — the pinned-first logic and localeCompare branch are already exercised by the Spanish test. Consider either removing the duplicate or choosing countries whose pt-BR alphabetical order diverges from Spanish to actually test locale-specific sorting.✅ **Test** - passed
✅ No issues found.
npm run test:country-localizationbash tests/run-test.sh npm run test:country-localizationnpm run build:frontendnpm run buildmanual behavioral verification script exercising getLocalizedCountryName, countryMatchesQuery, sortCountriesByLocalizedName across en/es/pt-BR/fa-IR locales✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.