Skip to content

Commit

Permalink
fix: do not show log message when defaultValue returns undefined beca…
Browse files Browse the repository at this point in the history
…use in this case no translation key is added

Fixes i18next#245
  • Loading branch information
kirillku committed Mar 18, 2023
1 parent e5eade7 commit ac0282d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,9 @@ class Parser {
? defaultValue(lng, ns, key, options)
: (options.defaultValue || defaultValue);
}
this.log(`Added a new translation key { ${chalk.yellow(JSON.stringify(resKey))}: ${chalk.yellow(JSON.stringify(resLoad[resKey]))} } to ${chalk.yellow(JSON.stringify(this.formatResourceLoadPath(lng, ns)))}`);
if (resLoad[resKey] !== undefined) {
this.log(`Added a new translation key { ${chalk.yellow(JSON.stringify(resKey))}: ${chalk.yellow(JSON.stringify(resLoad[resKey]))} } to ${chalk.yellow(JSON.stringify(this.formatResourceLoadPath(lng, ns)))}`);
}
} else if (options.defaultValue && (!options.defaultValue_plural || !resKey.endsWith(`${pluralSeparator}plural`))) {
if (!resLoad[resKey]) {
// Use `options.defaultValue` if specified
Expand Down

0 comments on commit ac0282d

Please sign in to comment.