-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In Trans.js, set default value to undefined as last possible option #462
In Trans.js, set default value to undefined as last possible option #462
Conversation
1 similar comment
isn't defaultValue not just used in case of the fallback not finding something: https://github.com/i18next/i18next/blob/master/src/Translator.js#L122 could you describe more / or make a sample what fallback mechanism you mean? |
Exactly, since defaultValue is set to a empty string and res is undefined, plus that skip the parseMissingKeyHandler function |
cause empty string is considered valid value per default: https://github.com/i18next/i18next/blob/master/src/defaults.js#L31 potentially this could break existing projects. could we make it a pick from reactI18nextOptions.defaultTransDefaultValueFallback which defaults to empty string so it will be backwards compatible |
beside how are you using the Trans component to not have a meaningful defaultValue...do you use it everywhere to just render plain strings not having a component interpolated? if so that could be done by just using the t function from the hoc, render prop |
We are using TypeScript, its easier to use Trans in our components than set the prop type to include t. Setting returnEmptyString to false fixes our issues but I feel like the default Trans value should undefined. On our side the issue is fixed with that workaround, this PR can be closed. |
will keep this open for now - will add the |
closing this for now...added an issue to keep that for future development: #577 sorry for not yet having time to do so...a PR would be welcome |
published in react-i18next@9.0.0 allow defining |
Using Trans component, if node is left empty, default value is set to a empty string. I18next will use that default value instead of its fallback mechanism. By setting the default value to undefined will let i18next define what fallback to use.