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 (#246)

Fixes #245
  • Loading branch information
kirillku committed Mar 19, 2023
1 parent e5eade7 commit 2832cb6
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 2832cb6

Please sign in to comment.