mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-12-18 12:31:47 +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>
|
<span>
|
||||||
{uiState === 'loading'
|
{uiState === 'loading'
|
||||||
? 'Translating…'
|
? 'Translating…'
|
||||||
: sourceLanguage && !detectedLang
|
: sourceLanguage && sourceLangText && !detectedLang
|
||||||
? `Translate from ${sourceLangText}`
|
? `Translate from ${sourceLangText}`
|
||||||
: `Translate`}
|
: `Translate`}
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
export default function localeCode2Text(code) {
|
export default function localeCode2Text(code) {
|
||||||
return new Intl.DisplayNames(navigator.languages, {
|
try {
|
||||||
type: 'language',
|
return new Intl.DisplayNames(navigator.languages, {
|
||||||
}).of(code);
|
type: 'language',
|
||||||
|
}).of(code);
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue