Fix error when language code is "startrek_it"

Srsly why…
pull/160/head
Lim Chee Aun 2023-06-05 11:40:30 +08:00
rodzic 618a0d70d2
commit 676fa6fbc9
2 zmienionych plików z 9 dodań i 4 usunięć

Wyświetl plik

@ -114,7 +114,7 @@ function TranslationBlock({
<span>
{uiState === 'loading'
? 'Translating…'
: sourceLanguage && !detectedLang
: sourceLanguage && sourceLangText && !detectedLang
? `Translate from ${sourceLangText}`
: `Translate`}
</span>

Wyświetl plik

@ -1,5 +1,10 @@
export default function localeCode2Text(code) {
return new Intl.DisplayNames(navigator.languages, {
type: 'language',
}).of(code);
try {
return new Intl.DisplayNames(navigator.languages, {
type: 'language',
}).of(code);
} catch (e) {
console.error(e);
return null;
}
}