Skip to content

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
@jamonholmgren
Copy link
Member

This looks awesome @whomwah! Thank you for the PR.

We'll wait for @mazenchami to get back from paternity leave, as he's the i18n expert here at Infinite Red, but it looks pretty good to me.

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.

3 participants