mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-12-18 07:12:52 +03:00
Fix error when language code is "startrek_it"
Srsly why…
This commit is contained in:
parent
618a0d70d2
commit
676fa6fbc9
2 changed files with 9 additions and 4 deletions
|
@ -114,7 +114,7 @@ function TranslationBlock({
|
|||
<span>
|
||||
{uiState === 'loading'
|
||||
? 'Translating…'
|
||||
: sourceLanguage && !detectedLang
|
||||
: sourceLanguage && sourceLangText && !detectedLang
|
||||
? `Translate from ${sourceLangText}`
|
||||
: `Translate`}
|
||||
</span>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue