Skip to content

feat(aliases): colonial-era, spelling & ASCII country name aliases - #179

Merged
dmythro merged 2 commits into
mainfrom
feat/country-aliases-historical
Jul 14, 2026
Merged

feat(aliases): colonial-era, spelling & ASCII country name aliases#179
dmythro merged 2 commits into
mainfrom
feat/country-aliases-historical

Conversation

@dmythro

@dmythro dmythro commented Jul 14, 2026

Copy link
Copy Markdown
Member

Follow-up to #178, also for 3.4.1. Extends getCountryCode name resolution beyond the recent-ISO-rename backward-compat set (which #178 covered) into curated historical and alternate names.

What's added — 36 aliases across 31 countries (~0.5 KB)

  • Colonial / independence-era former names: Rhodesia / Southern Rhodesia→ZW, Northern Rhodesia→ZM, Abyssinia→ET, Dahomey→BJ, Upper Volta→BF, Gold Coast→GH, Nyasaland→MW, Basutoland→LS, Bechuanaland→BW, South West Africa→NA, Formosa→TW, New Hebrides→VU, Ellice Islands→TV, Gilbert Islands→KI, British Honduras→BZ, Portuguese Guinea→GW, Dutch East Indies→ID, Spanish Sahara→EH, French Sudan→ML, Ubangi-Shari→CF, East Pakistan→BD, Tanganyika→TZ.
  • Spelling / transliteration variants: Byelorussia/Belorussia→BY, Moldavia→MD, Rumania/Roumania→RO, Bahrein→BH, Kirghizia/Kyrgyz Republic→KG, Turkmenia→TM, Macau→MO.
  • Diacritic-free forms (where the name/native carries diacritics): Cote d'Ivoire→CI, Turkiye→TR.
  • Short form: US→US — companion to the existing USA/America; the one short-form gap from Add alternative country names #35.

Each maps unambiguously to one current country — deliberately excludes ambiguous bare forms (no "Congo", no "Korea").

Why these / not more

  • No defunct states (USSR, Yugoslavia): those have no single current code and belong in the planned historical (ISO 3166-3) sub-module, not aliases.
  • No native-language variants or official long names (Kingdom of Belgium, Belgique/Belgien, etc. — the heart of Add alternative country names #35): open-ended, deferred as a dedicated follow-up sourced from CLDR/Wikidata.
  • Most diacritic-free forms already resolve (the dataset stores Curaçao/Réunion/Åland without diacritics), so only 2 ASCII gaps needed filling.

Safety & size

Verified

bun run ci green — lint, 3 typecheck targets, build, 22 tests. No generated dist/ committed (rebuilt at release).

Refs #35.

Extends getCountryCode name resolution with a curated historical set:

- Colonial / independence-era former names (Rhodesia, Abyssinia, Dahomey,
  Upper Volta, Gold Coast, Nyasaland, Formosa, New Hebrides, ...).
- Common spelling / transliteration variants (Byelorussia, Moldavia,
  Rumania, Bahrein, Kirghizia, Turkmenia, ...).
- Diacritic-free forms where the name/native carries diacritics
  (Cote d'Ivoire, Turkiye).

35 aliases across 31 countries, ~0.5 KB. All collision-checked by the
existing guard test — no name, native, or alias resolves to two countries.

Refs #35
@dmythro
dmythro requested a review from Copilot July 14, 2026 14:09
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Updated country data with historical aliases and spelling variants for multiple ISO2 entries, including expanded Türkiye and United States alias lists. Added tests verifying that names such as “Rhodesia,” “Abyssinia,” “Gold Coast,” “Formosa,” and “Rumania” resolve to the expected country codes.

Possibly related PRs

Poem

A rabbit hops through names of old,
Where Rhodesia’s tale is told.
Gold Coast, Formosa, Turkey too,
Find their country codes anew.
Historical names now gently align—
One lookup, one code, every time.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is detailed, but it omits verified source URL(s) for the data changes and does not clearly fill the Issue # field. Add the data source URL(s) used to verify the aliases and explicitly complete or remove the Issue # line per the template.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: adding historical and spelling-based country name aliases.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/country-aliases-historical

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Extends getCountryCode(name) backward-compatible name resolution by adding curated colonial-era, spelling/transliteration, and ASCII/diacritic-free country name aliases, plus a small regression-style test to exercise a representative subset.

Changes:

  • Added new alias entries for additional historical/spelling/ASCII variants in the countries dataset.
  • Expanded JS test coverage with a new test for several of the newly supported aliases.
  • Kept the existing guard tests ensuring aliases remain unambiguous and resolve to the owning country.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/test-js/getCountryCode.aliases.test.ts Adds a test covering several new colonial-era/spelling/ASCII alias resolutions.
packages/countries/src/data/countries.ts Adds curated alias strings to multiple countries to expand getCountryCode name matching.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/countries/src/data/countries.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/test-js/getCountryCode.aliases.test.ts (1)

22-30: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover all newly added aliases, or verify existing coverage.

This test validates 7 of the 35 added aliases. A table-driven test covering each new alias would catch data-entry errors in the remaining entries; otherwise, confirm that the other aliases are covered elsewhere.

🤖 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/test-js/getCountryCode.aliases.test.ts` around lines 22 - 30, Expand
the getCountryCode() alias coverage in the test 'getCountryCode() resolves
colonial-era names and spelling variants' to validate every newly added alias,
preferably using a table-driven set of alias-to-country expectations; if
remaining aliases are already tested elsewhere, verify and preserve that
coverage instead.
🤖 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/countries/src/data/countries.ts`:
- Line 417: Use consistently single-quoted literals for the Cote d'Ivoire alias
in packages/countries/src/data/countries.ts:417-417 and
packages/test-js/getCountryCode.aliases.test.ts:29-29, escaping the apostrophe
in each occurrence.

---

Nitpick comments:
In `@packages/test-js/getCountryCode.aliases.test.ts`:
- Around line 22-30: Expand the getCountryCode() alias coverage in the test
'getCountryCode() resolves colonial-era names and spelling variants' to validate
every newly added alias, preferably using a table-driven set of alias-to-country
expectations; if remaining aliases are already tested elsewhere, verify and
preserve that coverage instead.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1a903ac2-7033-4c8d-b837-9026470a4437

📥 Commits

Reviewing files that changed from the base of the PR and between ae60f8f and 03750c0.

📒 Files selected for processing (2)
  • packages/countries/src/data/countries.ts
  • packages/test-js/getCountryCode.aliases.test.ts

Comment thread packages/countries/src/data/countries.ts
Companion to 'USA'/'America' — 'US' is the most common short form and was
the one gap in issue #35's short-form list. Collision-free.
@dmythro
dmythro merged commit 66d92dd into main Jul 14, 2026
4 checks passed
@dmythro
dmythro deleted the feat/country-aliases-historical branch July 14, 2026 14:39
@dmythro dmythro mentioned this pull request Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants