Skip to content

Add Country demonym converter - #56

Open
LavX wants to merge 1 commit into
Diaoul:mainfrom
LavX:feat/country-demonym-converter
Open

Add Country demonym converter#56
LavX wants to merge 1 commit into
Diaoul:mainfrom
LavX:feat/country-demonym-converter

Conversation

@LavX

@LavX LavX commented Jun 8, 2026

Copy link
Copy Markdown

Summary

Adds a country demonym converter (the part of #38 you approved: a Country fromdemonym converter, without touching Language.fromname).

>>> Country('FR').demonym
'French'
>>> Country.fromdemonym('French')
<Country [FR]>

Change

  • New CountryDemonymConverter (registered as the internal demonym country converter), mirroring CountryNameConverter.
  • New bundled data file data/countrydemonym.txt (alpha2;demonym), generated from the mledoze/countries dataset. Demonyms are not part of any ISO standard, hence an external source.
  • Nine demonyms are shared by more than one country (e.g. French -> FR/TF, Dutch -> NL/BQ, American -> US/MP). Reverse lookups resolve to a documented primary chosen by population / common usage, kept in AMBIGUOUS_PRIMARY so the choices are visible and easy to adjust. All nine collisions are covered, so reverse() is deterministic.
  • Uninhabited Bouvet Island (BV) has no demonym and is the only country without one.

Forward convert() covers 248/249 countries; reverse resolves all 239 distinct demonyms to a valid country.

Closes #38

Convert between ISO 3166-1 alpha2 country codes and English demonyms:

    >>> Country('FR').demonym
    'French'
    >>> Country.fromdemonym('French')
    <Country [FR]>

Demonyms are not part of any ISO standard, so the data is generated from
the mledoze/countries dataset and bundled as data/countrydemonym.txt.
Nine demonyms are shared by more than one country (e.g. 'French' ->
FR/TF); reverse lookups resolve to a documented primary chosen by
population/common usage. Uninhabited Bouvet Island (BV) has no demonym.

Closes Diaoul#38
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.

Add new converters which uses country demonyms to convert languages

1 participant