Feature Request: Improved translation pluralisation support
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 234
- Forks
- 92
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 6
Description
Is your feature request related to a problem? Please describe.
The existing translation completions support pluralised translations, which is excellent, but there are a couple of edge cases that haven't yet been addressed.
- The
countvariable is not always rendered inside a translation, but still needed for the pluralisation logic to work. If a pluralised variable is injected,countshould be included with the variables regardless of if it is used inside the rendered string. - It’s possible that pluralised translations use different variables, so all should be accounted for. Currently it looks like only those in the first rule are used for autocompletions.
Describe the solution you'd like
Use case 1:
{
"product": {
"add_product_to_cart": {
"one": "Add product to cart",
"other": "Add products to cart"
}
}
}
In this example the completion should be:
{{ 'product.add_product_to_cart' | t: count: count }}
Despite count not being used in the actual rendered string, it is required for the pluralisation rules to work.
Use case 2:
{
"product": {
"add_count_product_to_cart": {
"one": "Add {{ product }} to cart, {{ test }}",
"other": "Add {{ product }}s to cart, {{ test_2 }}"
}
}
}
In this example the completion should be:
{{ 'product.add_product_to_cart' | t: count: count, product: product, test: test, test_2: test_2 }}
Variables discovered in all options should be completed to ensure the string can always render correctly.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No file or test is named. Start by locating the translation completion generation logic and trace how pluralized translation options are inspected. Done means completions include count when pluralization requires it and include variables discovered across every pluralization option.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100