i18next-parser icon indicating copy to clipboard operation
i18next-parser copied to clipboard

keepRemoved: false does not remove unneeded plurals

Open amandapouget opened this issue 3 years ago • 1 comments

🐛 Bug Report

When the translation file contains plural forms not needed for a locale and keepRemoved: false is set, the parser fails to remove the unneeded plurals.

To Reproduce

(I tried valiently to create a sandbox but unfortunately the link in this PR template leads to a very generic set of search results for "Example" sandboxes. I painstakingly put together a sandbox only to realize that by starting with one of the react templates, I had inadvertently chosen one to which it is impossible to execute a terminal command. :-(

If the PR template is updated to include a link to a forkable sandbox with a terminal, I will sandbox this.)

// en-US

{
  "someKey_one": "some value",
  "someKey_other": "some value",
  "someKey_many": "some value",
}

// parser config

keepRemoved: false

Expected behavior

I expect running the parser to remove the _many entry in the English file, but it does not.

{
  "someKey_one": "some value",
  "someKey_other": "some value",
}

Your Environment

  • runtime version: 14.17.3 node
  • i18next version: 5.3.0
  • os: Mac
  • any other relevant information

This is the line of code I think should be locale sensitive: https://github.com/i18next/i18next-parser/blob/054e29a7b0cae3860857cb0cd5b0d5eac2dd1d0a/src/helpers.js#L239

amandapouget avatar Dec 02 '21 03:12 amandapouget

@amandapouget The best is really to open a PR with a failing test case. A PR would be welcome to fix this.

karellm avatar Dec 03 '21 03:12 karellm