i18next / i18next-parser

Parse your code to extract translation keys/values and manage your catalog files
MIT License
466 stars 189 forks source link

Extract plurals from code #998

Open joshhunt opened 2 months ago

joshhunt commented 2 months ago

🚀 Feature Proposal

I would like to extract all plural forms from the code, rather than only a single form, and then having to update the .json file with other plural forms

I'm not exactly sure of the API for this, and whether it would require additions to i18next core.

Motivation

So we have one single way for developers to write phrases, and plurals are properly translated.

Example

Perhaps, something like:

t.plural("folder-count", {
  one: "{{count}} folder",
  other: "{{count}} folders",
}, { count })

Which, after running i18next-parser, would output

{
  "folder-count_one": "{{count}} folder",
  "folder-count_other": "{{count}} folders",
}

A similar API could exist for <Trans /> as well.