这是indexloc提供的服务,不要输入任何密码
Skip to content

feat(i18n): add support for i18next pluralization keys #2980

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

whomwah
Copy link

@whomwah whomwah commented Jul 18, 2025

Currently the i18n keys typing doesn't support pluralisation as you store the keys with a suffix and target them without [https://www.i18next.com/translation-function/plurals].

Introduced types for plural suffixes and a helper to strip them from keys. This enhances the translation key management in the i18n module.

Checklist

  • I have manually tested this, including by generating a new app locally.

Testing

const en = {
  common: {
    ...
    demo_one: "demo",
    demo_other: "demos",
  },
}

translate("common:demo", { count: 1 }) => "demo"
translate("common:demo", { count: 2 }) => "demos"
CleanShot 2025-07-18 at 16 45 57
> yarn run test
yarn run v1.22.22
$ jest
 PASS  app/services/api/apiProblem.test.ts
 PASS  test/i18n.test.ts
 PASS  app/utils/storage/storage.test.ts
 PASS  app/components/Text.test.tsx

Test Suites: 4 passed, 4 total
Tests:       20 passed, 20 total
Snapshots:   0 total
Time:        3 s
Ran all test suites.
✨  Done in 4.37s.

PizzaApp on  main via  v20.13.1 took 4s
> yarn run lint:check
yarn run v1.22.22
$ eslint .
✨  Done in 4.19s.

PizzaApp on  main via  v20.13.1 took 4s
> yarn run compile
yarn run v1.22.22
$ tsc --noEmit -p . --pretty
✨  Done in 2.09s.

Introduced types for plural suffixes and a helper to strip them from keys. This enhances the translation key management in the i18n module.
@whomwah whomwah force-pushed the feat/add-pluralisation-typing branch from 0ad6bec to 79ebc40 Compare July 18, 2025 15:52
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.

1 participant