Use one source for country names: Regions list and details currently disagree
The problem
Changing a country's name in the database produces two different names in Medusa Admin:
| Screen | Name shown | Where it comes from |
|---|---|---|
| Settings → Regions → Countries column | Original name | A hard-coded list in the frontend |
| Open a region → Countries table | Updated name | The API, backed by the database |
Both screens receive country records from the API. The Regions list ignores the returned display_name and looks up a name in its own static list instead.
Could Admin use the database/API as the single source for country names? Would you welcome a PR to do this?
How to reproduce
Tested with Medusa and Dashboard 2.21.1, PostgreSQL, and the standard Admin.
Create a region containing a country, such as
tw.With the backend running, change its display name in a disposable local database:
UPDATE region_country SET display_name = 'Country label test' WHERE iso_2 = 'tw';Refresh Settings → Regions. The Countries column still shows the original name.
Open that region. Its Countries table shows Country label test.
The country code is just an example. The difference is in how the two screens read the name.
There is also a persistence issue: restarting the backend can reset the database name because the defaults loader upserts the bundled names again.
Proposed fix
- Use the name already returned by the API. The Regions list should render
country.display_name, just like the detail page. - Provide an API for the full country list. Country selectors need all countries, not only those assigned to a region. The database already contains that list—250 records in our local installation—but Admin currently uses frontend constants for these selectors.
- Preserve customized names on restart. Bundled defaults should initialize missing countries without silently replacing customized names. The policy for updating existing default names needs maintainer input.
Country codes would remain unchanged. This is about display names, not changing country identifiers or region membership.
Source-code references
List:
packages/admin/dashboard/src/components/table/table-cells/region/countries-cell/countries-cell.tsxlooks up the frontend constant:COUNTRIES.find((c) => c.iso_2 === country.iso_2)?.display_nameDetails:
region-country-section.tsxpasses API-providedregion.countriestouseCountries.use-country-table-columns.tsxthen renders each record'sdisplay_namedirectly.Selectors: the comment in
use-countries.tsxsays static country data is used because countries cannot be retrieved from an API.Startup:
packages/modules/region/src/loaders/defaults.tsupserts the bundled country names into the database.
Related: #16522 proposes localized country labels via Intl.DisplayNames. This issue asks which source Admin should use consistently, including when a persisted label has been customized.
Implementation prompt
If this direction is accepted, here is a suggested brief for a contributor or coding agent:
Make Medusa Admin read country names consistently from the Region database through APIs.
- Find the Admin components that display or select countries.
- Where a component already receives a country record, use its
display_nameinstead of looking up a frontend constant.- Add an authenticated, read-only Admin API for all countries, including unassigned ones. Follow existing API conventions and use it in full-country selectors.
- Apply the maintainer-approved startup policy: add missing countries while preserving customized names.
- Keep ISO codes and existing commerce behavior unchanged.
- Add regression coverage for matching list/detail names, selecting unassigned countries, and preserving customized names across startup.
Flag any remaining static-name consumers that need separate work.
Before I open a PR
- Is there a reason the Regions list deliberately uses static names instead of the API's names?
- Would you accept the database/API as the shared source?
- Should I start with a small PR fixing list/detail consistency, then address the full-country API and startup behavior separately?
Happy to contribute once we agree on the direction and scope.
Source: medusajs/medusa