eris/utils/getFlagEmoji.ts

54 lines
2.1 KiB
TypeScript
Raw Permalink Normal View History

2023-09-13 09:50:22 +00:00
/** Language to biggest country emoji map */
const languageToFlagMap: Record<string, string> = {
2023-09-22 02:59:22 +00:00
"en": "🇺🇸", // english - united states
"zh": "🇨🇳", // chinese - china
"es": "🇪🇸", // spanish - spain
"hi": "🇮🇳", // hindi - india
"ar": "🇪🇬", // arabic - egypt
"pt": "🇧🇷", // portuguese - brazil
"bn": "🇧🇩", // bengali - bangladesh
"ru": "🇷🇺", // russian - russia
"ja": "🇯🇵", // japanese - japan
"pa": "🇮🇳", // punjabi - india
"de": "🇩🇪", // german - germany
"ko": "🇰🇷", // korean - south korea
"fr": "🇫🇷", // french - france
"tr": "🇹🇷", // turkish - turkey
"ur": "🇵🇰", // urdu - pakistan
"it": "🇮🇹", // italian - italy
"th": "🇹🇭", // thai - thailand
"vi": "🇻🇳", // vietnamese - vietnam
"pl": "🇵🇱", // polish - poland
"uk": "🇺🇦", // ukrainian - ukraine
"uz": "🇺🇿", // uzbek - uzbekistan
"su": "🇮🇩", // sundanese - indonesia
"sw": "🇹🇿", // swahili - tanzania
"nl": "🇳🇱", // dutch - netherlands
"fi": "🇫🇮", // finnish - finland
"el": "🇬🇷", // greek - greece
"da": "🇩🇰", // danish - denmark
"cs": "🇨🇿", // czech - czech republic
"sk": "🇸🇰", // slovak - slovakia
"bg": "🇧🇬", // bulgarian - bulgaria
"sv": "🇸🇪", // swedish - sweden
"be": "🇧🇾", // belarusian - belarus
"hu": "🇭🇺", // hungarian - hungary
"lt": "🇱🇹", // lithuanian - lithuania
"lv": "🇱🇻", // latvian - latvia
"et": "🇪🇪", // estonian - estonia
"sl": "🇸🇮", // slovenian - slovenia
"hr": "🇭🇷", // croatian - croatia
"zu": "🇿🇦", // zulu - south africa
"id": "🇮🇩", // indonesian - indonesia
"is": "🇮🇸", // icelandic - iceland
"lb": "🇱🇺", // luxembourgish - luxembourg
2023-10-08 18:23:31 +00:00
"ca": "🇪🇸", // catalan - spain
2023-09-13 09:50:22 +00:00
};
export function getFlagEmoji(languageCode?: string): string | undefined {
2023-09-26 11:25:13 +00:00
if (!languageCode) return;
const language = languageCode.split("-").shift()?.toLowerCase();
if (language == null) return;
return languageToFlagMap[language] ?? `[${language.toUpperCase()}]`;
2023-09-13 09:50:22 +00:00
}