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