Closed vricosti closed 3 years ago
Ok some I kept on searching for my issue and there was some errors in my code with bad naming en-US and en_US so now I have fixed it actually the default behavior doesnt work at all as I thought. When a json file exists and a key has an empty translation (let's say username) it displays an empty string but is it possible in this case to at least display the key itself because displaying something is better than empty ? Even better when a translation is empty (let's say in japanese) would it be possible to have a fallback to take english translation and if english is not translated to take the key ? Is it supported ?
Actually my question is: is it possible to have a fallback not when a translation is not available but when it's empty ?
What is a motivation to use empty string instead of no key (undefined)?
Close due to in-activity if you still have the issue, please you would be possible open as a new issue. When you do, please give us a clear explanation.
Thanks!
Missing values for existing keys In addition to the above, if you want missing values to fallback to the key in cases where the keys (e.g. got extracted by a code parser) exist in your JSON translation file with empty string as value, you also need this setting:
returnEmptyString: false
In addition to the above, if you want missing values to fallback to the key in cases where the keys (e.g. got extracted by a code parser) exist in your JSON tran
Does vue i18n support returnEmptyString: false ? Mine doesn't work.
I am using vue-i18n (8.25.0) with the following configuration:
main.js
plugins/Translations.js:
plugins/i18n.js
I have 2 locales en-US and fr-FR where fr-FR has no translations for now. lang/en-US.json
lang/fr-FR.json
Inside main.js Trans.Init is called to query the wanted locale from a rest API then changeLanguage then setI18nLanguageInServices. Once the language has been changed in fr-FR for instance (ie setI18nLanguageInServices has returned) all my texts are empty because it doesn't take the key if not translation is found. On the contrary if I comment inside setI18nLanguageInServices the line Trans.currentLanguage = lang then the texts are in english and not in french but at least the key is displayed. So why once the language is changed it doesn't display the key if no translation is found (default behavior)