File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
src/components/LanguagePicker Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -71,8 +71,14 @@ export const useLanguagePicker = (
71
71
const fallbackSource =
72
72
intlSource !== localeOption ? intlSource : englishName
73
73
const i18nKey = "language-" + localeOption . toLowerCase ( )
74
- const i18nSource = t ( i18nKey )
75
- const sourceName = i18nSource === i18nKey ? fallbackSource : i18nSource
74
+ const i18nSource = t ( i18nKey ) // Falls back to English namespace if not found
75
+
76
+ // If i18nSource (fetched from `language-{locale}` in current namespace)
77
+ // is not translated (output === englishName), or not available
78
+ // (output === i18nKey), use the Intl.DisplayNames result as fallback
79
+ const sourceName = [ i18nKey , englishName ] . includes ( i18nSource )
80
+ ? fallbackSource
81
+ : i18nSource
76
82
77
83
// Get "target" display name (Language choice displayed in that language)
78
84
const fallbackTarget = new Intl . DisplayNames ( [ localeOption ] , {
You can’t perform that action at this time.
0 commit comments