Add Wales/Scotland/Northern Ireland/England to country selection Closes #1484

This commit is contained in:
Kalle 2025-10-04 11:52:36 +03:00
parent 9edc6b363f
commit 64cea2abee
4 changed files with 23 additions and 7 deletions

View File

@ -110,6 +110,10 @@ export const COUNTRY_CODES = [
"FR",
"GA",
"GB",
"GB-ENG",
"GB-NIR",
"GB-SCT",
"GB-WLS",
"GD",
"GE",
"GF",

View File

@ -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");
}

View File

@ -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", () => {

View File

@ -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 (