Skip to content
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

[question] about log "Translation key "myKey" has multiple different default values. Using first default" #69

Closed
cournoll opened this issue Jan 16, 2018 · 6 comments

Comments

@cournoll
Copy link

cournoll commented Jan 16, 2018

When I generate two translation files (en and de) after modifying the "de" file, I have this log.

en-translations.json :

{  
  "To get started, edit <1>src/App.js</1> and save to reload.": "To get started, edit <1>src/App.js</1> and save to reload.",
  "Welcome to React": "Welcome to React"
}

de-translations.json :

{
  "To get started, edit <1>src/App.js</1> and save to reload.": "Starte in dem du, <1>src/App.js</1> editierst und speicherst.",
  "Welcome to React": "Willkommen bei React und react-i18next"
}

console :
i18next-scanner: Translation key "To get started, edit <1>src/App.js</1> and save to reload." has multiple different default values. Using first default

Can you explain to me why this happen with tag and not with t() function ?

Thanks for your help.

@cheton
Copy link
Member

cheton commented Jan 16, 2018

Hi @wichert

There is a warning message about default conflict that was added in this commit:
c309f09#diff-6947033678b93d106e25614dd972e66f

But, there should be no default value for other languages that need to translate.

How about showing the warning message only for the first item (i.e. the default language) of the "lngs" array. That is, it will omit the warning message for 'de' and 'fr' languages with the example below:

{
    lngs: ['en', 'de', 'fr'] // array of supported languages
}

@cournoll
Copy link
Author

Thank you for quick response.

@cheton
Copy link
Member

cheton commented Jan 17, 2018

@thibaudcournollet

This warning will not cause any issues to your current work, but we may need to suppress this warning message to prevent false positives.

@wichert
Copy link
Contributor

wichert commented Jan 19, 2018

@cheton Your suggestion definitely makes sense. I'm not sure how to accomplish that though?

@cheton
Copy link
Member

cheton commented Jan 20, 2018

@wichert
How about adding a "defaultLng" option? If the option is missing, use the first item of the lngs array as defaultLng. Then, we can do the comparison like below:

} else if ((resLoad[resKey] !== options.defaultValue) && (lng === defaultLng)) {
    // We already had a different default.
    const k = chalk.yellow(JSON.stringify(resKey));
    this.log(`i18next-scanner: Translation key ${k} has multiple different default values. Using first default`);
}

@cheton cheton closed this as completed in 891fa2c Jan 20, 2018
@cheton
Copy link
Member

cheton commented Jan 20, 2018

Fixed in v2.4.1

891fa2c Add a defaultLng option for checking default values

{
    defaultLng: 'en'
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants