fix: language flags

This commit is contained in:
pinks 2023-09-26 13:25:13 +02:00
parent 82fdd0f21c
commit 01261b6f3a
1 changed files with 4 additions and 3 deletions

View File

@ -45,7 +45,8 @@ const languageToFlagMap: Record<string, string> = {
};
export function getFlagEmoji(languageCode?: string): string | undefined {
const language = languageCode?.split("-").pop()?.toLowerCase();
if (!language) return;
return languageToFlagMap[language];
if (!languageCode) return;
const language = languageCode.split("-").shift()?.toLowerCase();
if (language == null) return;
return languageToFlagMap[language] ?? `[${language.toUpperCase()}]`;
}