diff --git a/src/components/translation-block.jsx b/src/components/translation-block.jsx index 5183af03..4512b689 100644 --- a/src/components/translation-block.jsx +++ b/src/components/translation-block.jsx @@ -114,7 +114,7 @@ function TranslationBlock({ {uiState === 'loading' ? 'Translating…' - : sourceLanguage && !detectedLang + : sourceLanguage && sourceLangText && !detectedLang ? `Translate from ${sourceLangText}` : `Translate`} diff --git a/src/utils/localeCode2Text.jsx b/src/utils/localeCode2Text.jsx index d3a1b970..e9843ace 100644 --- a/src/utils/localeCode2Text.jsx +++ b/src/utils/localeCode2Text.jsx @@ -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; + } }