Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature to skip identical keys for specified locales #1057

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Aryan-mor
Copy link

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

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

Implemented logic to skip keys with identical values for specified locales in the i18next parser. Added tests to verify behavior and updated existing code to accommodate the new feature.
@Aryan-mor Aryan-mor marked this pull request as draft August 15, 2024 14:50
Enhanced the translation skipping functionality to handle plural forms. Added new test cases for plural translations in 'ar' and 'fr' locales. Updated helpers and transformation logic to identify and process plural keys correctly.
@Aryan-mor Aryan-mor marked this pull request as ready for review August 15, 2024 15:58
@codecov-commenter
Copy link

codecov-commenter commented Aug 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

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              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@karellm
Copy link
Member

karellm commented Aug 19, 2024

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?

@omid
Copy link

omid commented Aug 19, 2024

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Config to remove key/value, if key=value
4 participants