diff --git a/app/features/user-page/user-page-constants.ts b/app/features/user-page/user-page-constants.ts index 1c3f3961b..1f891fc25 100644 --- a/app/features/user-page/user-page-constants.ts +++ b/app/features/user-page/user-page-constants.ts @@ -110,6 +110,10 @@ export const COUNTRY_CODES = [ "FR", "GA", "GB", + "GB-ENG", + "GB-NIR", + "GB-SCT", + "GB-WLS", "GD", "GE", "GF", diff --git a/app/styles/flags.css b/app/styles/flags.css index c0afa3c87..ef5a20fae 100644 --- a/app/styles/flags.css +++ b/app/styles/flags.css @@ -994,3 +994,15 @@ .twf-gb-wls { background-image: url("https://cdn.jsdelivr.net/gh/twitter/twemoji@14.0.2/assets/svg/1f3f4-e0067-e0062-e0077-e006c-e0073-e007f.svg"); } + +.twf-gb-eng { + background-image: url("https://cdn.jsdelivr.net/gh/twitter/twemoji@14.0.2/assets/svg/1f3f4-e0067-e0062-e0065-e006e-e0067-e007f.svg"); +} + +.twf-gb-sct { + background-image: url("https://cdn.jsdelivr.net/gh/twitter/twemoji@14.0.2/assets/svg/1f3f4-e0067-e0062-e0073-e0063-e0074-e007f.svg"); +} + +.twf-gb-nir { + background-image: url("https://cdn.jsdelivr.net/gh/twitter/twemoji@14.0.2/assets/svg/1f1ec-1f1e7.svg"); +} diff --git a/app/utils/i18n.test.ts b/app/utils/i18n.test.ts index 9e76874d5..030e8ec4b 100644 --- a/app/utils/i18n.test.ts +++ b/app/utils/i18n.test.ts @@ -10,12 +10,12 @@ describe("countryCodeToTranslatedName()", () => { expect(result).toBe("Suomi"); }); - it("returns the country code if it contains a dash (Intl.DisplayNames throws)", () => { + it("returns the country name in english if the code contains a dash", () => { const result = countryCodeToTranslatedName({ countryCode: "GB-WLS", - language: "en", + language: "fi", }); - expect(result).toBe("GB-WLS"); + expect(result).toBe("Wales"); }); it("returns the country code as is for unknown country", () => { diff --git a/app/utils/i18n.ts b/app/utils/i18n.ts index e68eab63f..1e4535b9f 100644 --- a/app/utils/i18n.ts +++ b/app/utils/i18n.ts @@ -21,10 +21,10 @@ export function countryCodeToTranslatedName({ countryCode: string; language: string; }) { - // known limitation, function cannot handle e.g. GB-WLS (Wales) - if (countryCode.includes("-")) { - return countryCode; - } + if (countryCode === "GB-WLS") return "Wales"; + if (countryCode === "GB-SCT") return "Scotland"; + if (countryCode === "GB-NIR") return "Northern Ireland"; + if (countryCode === "GB-ENG") return "England"; try { return (