-
-
Notifications
You must be signed in to change notification settings - Fork 129
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
Control over translations being added #208
Comments
@Poky85 It seems to already support this behavior. |
@Toilal Which version? Could you post the code showing how to achieve this behavior? |
I run v3.0.0, here's my configuration file. My main language is French. module.exports = {
options: {
ns: ['app'],
defaultNs: 'app',
removeUnusedKeys: true,
sort: true,
func: {
list: ['i18next.t', 'i18n.t', 'i18nKey', 't', 'tl', '\\$t', '\\$tl'],
extensions: ['.ts', '.vue']
},
trans: {
component: 'Trans',
extensions: []
},
lngs: ['fr-FR', 'en-GB'],
fallbackLng: 'fr-FR',
defaultLng: 'fr-FR',
defaultValue: (lng, ns, key, entry) => {
if (lng !== 'fr-FR') {
return
}
return entry.defaultValue
},
resource: {
loadPath: 'src/i18n/{{lng}}/{{ns}}.json',
savePath: 'src/i18n/{{lng}}/{{ns}}.json',
jsonIndent: 2,
lineEnding: '\n'
}
}
} |
@Poky85 I still have issues in some cases (plurals). It seems https://github.com/i18next/i18next-parser works better, you should have a look. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
🚀 Feature Proposal
Currently keys that doesn't exist in resource files are added for all languages defined in
options.lngs
. E.g. when your application has dictionaries in 5 languages and mydefaultValue
is empty string, then new keys are added in all languages.In my i18next app i use fallback language. So translations which doesn't exist in user's language are loaded from fallback language:
Empty string translations doesn't fallback by default, but I would have to set:
With config above, it fallbacks even when having empty strings in resource files.
I would like to have keys in resource file only when they are translated. Empty strings are unnecessary.
I think we could use
defaultValue
option for this, see an example.Motivation
For me empty strings in dictionary files are completely unnecessary and I would like to add new translations to
fallbackLng
only. In our project developer usually creates message infallbackLng
only, then translations for other languages are added in translation service. Having empty strings unnecessarily increases file size of dictionaries when loaded in browser.From my experience some translation services have a problem with empty strings. They don't return empty strings in export which means that empty translations are added by scanner and then removed by translation service. And this happens over and over again until key gets translated.
Example
What do you think the idea?
The text was updated successfully, but these errors were encountered: