Skip to content

Commit

Permalink
Fix undefined issue when language toggle to Nederlands
Browse files Browse the repository at this point in the history
- Related to #6425
  • Loading branch information
royallsilwallz committed May 13, 2024
1 parent 6e53dc6 commit 0f4a545
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions frontend/src/utils/countries.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getCountries, getCountry, getSupportedLangs } from '@hotosm/iso-countri

export function translateCountry(name, locale) {
const code = getCountryCode(name);
if (code && isLangSupported(locale)) return getCountry(locale.split('-')[0], code);
if (code && isLangSupported(locale)) return getCountry(locale.split(/[-_]/)[0], code);
return name;
}

Expand All @@ -27,7 +27,7 @@ export function isLangSupported(code) {

export function formatCountryList(locale) {
if (locale && isLangSupported(locale)) {
const countries = getCountries(locale.split('-')[0]);
const countries = getCountries(locale.split(/[-_]/)[0]);
return Object.keys(countries).map((key) => ({ label: countries[key], value: key }));
}
}
Expand Down

0 comments on commit 0f4a545

Please sign in to comment.