Skip to content

failOnUpdate fails when no update happens, when using namespaces #597

@JulioC

Description

@JulioC

🐛 Bug Report

When using failsOnUpdates flag, the transformers emits an error even when no update is necessary. This only happens when using multiple namespaces.

It appears that the cause is that the namespaces won't be considered for the original number of tokens when calculating the change count (see below).

if (this.options.failOnUpdate) {
const addCount = uniqueCount[namespace] - mergeCount
if (addCount + restoreCount + oldCount !== 0) {
this.parserHadUpdate = true
continue
}
}

To Reproduce

Consider the JS below (or any code you have)

t('ns1:key1', 'Key 1');
t('ns2:key2', 'Key 1');

Now run the CLI against it to generate the JSON files, without failOnUpdate. This should run fine.

Finally, run the CLI once again, but this time add --fail-on-update. This will fail even without changes in JS source.

You can check that no update is necessary by add running the CLI without that flag once again.

Also, run with --fail-on-update --verbose to see the incorrect totals.

Expected behavior

It should only emit an error when update is necessary

Your Environment

  • runtime version: i.e. node v16
  • i18next version: i.e. 6.4.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions