From 5550d184bb834bf839290f294bb7b3b4ec24a1ef Mon Sep 17 00:00:00 2001 From: Benjamin Canac Date: Thu, 26 Dec 2024 10:59:21 +0100 Subject: [PATCH] docs(SupportedLanguages): improve --- .../components/content/SupportedLanguages.vue | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/docs/app/components/content/SupportedLanguages.vue b/docs/app/components/content/SupportedLanguages.vue index 1b79ec92..c0859046 100644 --- a/docs/app/components/content/SupportedLanguages.vue +++ b/docs/app/components/content/SupportedLanguages.vue @@ -8,29 +8,24 @@ const props = withDefaults(defineProps<{ }) function getEmojiFlag(locale: string): string { - // Map language codes to default country codes const languageToCountry: Record = { - en: 'gb', ar: 'sa', cs: 'cz', - zh: 'cn', + da: 'dk', + el: 'gr', + en: 'gb', ja: 'jp', ko: 'kr', - uk: 'ua' + uk: 'ua', + zh: 'cn' } - // Get base language code before any region specifier const baseLanguage = locale.split('-')[0]?.toLowerCase() || locale - - // Use mapped country code or extract from locale if it contains a region const countryCode = languageToCountry[baseLanguage] || locale.replace(/^.*-/, '').slice(0, 2) - return countryCode + return countryCode.toUpperCase() .split('') - .map((char: string) => { - const codePoint = char.toUpperCase().codePointAt(0) - return codePoint ? String.fromCodePoint(0x1F1A5 + codePoint) : '' - }) + .map(char => String.fromCodePoint(0x1F1A5 + char.charCodeAt(0))) .join('') }