Recently, I've been utilizing i18next
, and I decided to set a fallback value for some translated strings in case they are not available in the selected language. Here's an example:
en:
base.json
"yes": "yes"
"no": "no"
fr:
base.json
"yes": "oui"
"no: ""
The behavior I expect is that when the app is running on FR
and I try to access {{ i18n.t('base:no' }}
, the output should be no
instead of an empty string.
Here's what I have attempted so far:
Initialization:
i18next
.use(languageDetector)
.init({
fallbackLng: 'en',
load: 'languageOnly',
detection: {
order: ['querystring', 'navigator']
}
})
When trying to output:
{{ i18n.t('base:no', {lng: 'en'} }}
, all I get is an empty string.
I also tried loading the fallback language during initialization, but it didn't seem to work.
Has anyone encountered this issue before? Any help would be greatly appreciated!