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

Module removes all key forms from target locale if target locale uses only 1 form (no plurals) #40

Closed
javnik36 opened this issue Feb 26, 2025 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@javnik36
Copy link

Describe the bug
Hey,
I guess I found that i18next-locales-sync has currently some problem with syncing locales with only 1 form (no plurals, like korean or japanese). When I try the example from readme:

// /examples/en/namespace.json
{
  "foo_male": "bar-male-en",
  "room_one": "room",
  "room_other": "rooms"
}
// /examples/ja/namespace.json
{
  "foo_male": "bar-male-ja",
  "room": "部屋",
  "room_other": "部屋"
}

After running npx i18next-locales-sync -p en -s ja -l ./examples, I'm getting this:

// /examples/ja/namespace.json
{
  "foo_male": "bar-male-ja"
}

Both room keys are removed from target ja file.

Expected behavior
Module keeps relevant translation/key if target locale has only 1 form.

Environment (please complete the following information):

@javnik36 javnik36 added the bug Something isn't working label Feb 26, 2025
@felixmosh
Copy link
Owner

Hi, thank u for reporting this issue.

There is a test for this case, https://github.com/felixmosh/i18next-locales-sync/blob/master/test/syncJson/plurals.test.ts#L43

The source locale should have "room" key without any plural form, correct?

@javnik36
Copy link
Author

Right, having plain "room" key in source file keeps existing plural forms in "ja" target.

Although running module without plain "room" key in source, properly populates all forms in target locales - in locales that have any (e.g. targeting "pl" correctly creates all plural forms even without plain "room" key in source) in against to "ja"-like target locales (plain "room" isn't created either).

@felixmosh
Copy link
Owner

Let me check this deeper....

@felixmosh
Copy link
Owner

felixmosh commented Feb 26, 2025

Fixed in v2.1.1, thank you 🙏🏽

@javnik36
Copy link
Author

Great! That was fast, thanks for your work.

Following on that issue, I have one last case (if you wish another issue created for this let me know) - creating a new locale (or updating existing one without given key) out of source locale without plain key (aka "room") does not create it in target locale, that do not use plurals.

Example:
Source:

// /examples/en/namespace.json
{
  "room_one": "room",
  "room_other": "rooms"
}

Target: "ja" - does not exist, or does not contain "room"
Output: empty file ({}) or no key created

Checked on v2.1.1.

@felixmosh
Copy link
Owner

This case doesn't make any sense, your source language most have none plural version....

What value should be used from the source?

@felixmosh
Copy link
Owner

Please open a separate issue for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants