Adding new flags for supported locales (#420)

* Adding new flags for supported locales
* Removing pl-PL locale code from tests
* Linting
This commit is contained in:
jarek
2023-02-04 00:56:24 +01:00
committed by GitHub
parent 65c8bec2b4
commit 5a324f1358
6 changed files with 70 additions and 14 deletions

View File

@@ -75,7 +75,12 @@ export function getCountryCode(locale: string) {
if (locale === 'en') { return 'US'; }
let countryCode = locale.split(/[-_]/)[1];
if (countryCode) { return countryCode.toUpperCase(); }
countryCode = locale.toUpperCase();
// Some defaults that we support and can't be read from language code.
countryCode = {
'uk': 'UA', // Ukraine
}[locale] ?? locale.toUpperCase();
// Test if we can use language as a country code.
if (localeCodes.map(code => code.split(/[-_]/)[1]).includes(countryCode)) {
return countryCode;