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

Add feature to skip identical keys for specified locales

Open Aryan-mor opened this issue 1 year ago • 3 comments

Implemented logic to skip keys with identical values for specified locales in the i18next parser. Fixes #1036

Why am I submitting this PR

Please refer to #1036

Does it fix an existing ticket?

Yes #1036

Checklist

  • [x] only relevant code is changed (make a diff before you submit the PR)
  • [x] tests are included and pass: yarn test (see details here)
  • [x] documentation is changed or added

Aryan-mor avatar Aug 15 '24 14:08 Aryan-mor

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 95.47%. Comparing base (168c8d5) to head (2a02abc). Report is 65 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1057      +/-   ##
==========================================
+ Coverage   95.40%   95.47%   +0.06%     
==========================================
  Files          11       10       -1     
  Lines        1937     1965      +28     
==========================================
+ Hits         1848     1876      +28     
  Misses         89       89              

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Aug 19 '24 10:08 codecov-commenter

I'm a bit puzzled by this use case but I don't really like the implementation.

First it looks very specific to a use case you have (not something many people would need). Second the option name skipIdenticals shouldn't remove empty values imo. That said, I don't want to make the API too complex with an extra skipEmtpy.

I actually think that the best solution here is to add hooks. We could have an hook to update the catalog before it is written to file. You could then add the logic you need in there.

What do you think?

karellm avatar Aug 19 '24 10:08 karellm

@karellm I can answer about the use case. If you have worked with gettext (i18next has gettext tag on npm) you know in gettext, you write translations like t('The Default Language Text') and mostly the default language (which is EN by default) translation file is almost empty.

We can rename the name skipIdentical to elaborate the use case. I agree, and we can have another array for skipEmpty to skip empties in some languages. On the other hand, it can be more objective, like refer to defaultLanguages.

omid avatar Aug 19 '24 14:08 omid