Comfy-Org / Comfy-Org/ComfyUI_frontend

i18n: register CLDR pluralRules — ru and ar select the wrong plural form

Open
#15,647 1 comment 0 reactions 1 assignee Claimed by @benceruleanlu View on GitHub
area:i18n Potential Bug
Dominant language
TypeScript
Stars
2k
Forks
704
Avg merge
1d 8h
Merged PRs (30d)
512

Description

## Problem

`src/i18n.ts` registers no `pluralRules`, so vue-i18n falls back to `pluralDefault`
(`@intlify/core-base@11.2.8`, `core-base.mjs:1334`):

```js
function pluralDefault(choice, choicesLength) {
choice = Math.abs(choice);
if (choicesLength === 2) {
return choice ? (choice > 1 ? 1 : 0) : 1;
}
return choice ? Math.min(choice, 2) : 0;
}
```

That is magnitude-based selection. It cannot express the CLDR rules for Slavic or
Semitic languages, which select by modulo rather than size.

## Impact

Measured against the corpus in https://github.com/Comfy-Org/ComfyUI_frontend/pull/15230
(plural-form counts per locale in `src/locales/*/main.json`, over the 46 English strings
that use `|`):

| locale | 1 form | 2 forms | 3 forms |
| --- | --- | --- | --- |
| ru | 3 | 17 | **26** |
| ar | 3 | **41** | 2 |
| tr | 8 | 36 | 2 |
| pt-BR | 5 | 39 | 2 |

- **Russian, 26 strings.** With 3 forms, `pluralDefault` returns `Math.min(count, 2)`.
So `count = 2, 3, 4` select index 2 — the same form as `count = 5`. Russian CLDR needs
*few* for 2–4 and *many* for 5–20. Every count in 2–4 renders the wrong form.
- **Arabic, 41 strings.** With 2 forms, `count === 0` returns index 1 — the plural form.
Arabic has a distinct zero category, and a distinct dual for `count === 2`.

## Why this is not just a corpus problem

https://github.com/Comfy-Org/ComfyUI_frontend/pull/15230 identifies this in its own
description — the repaired `g.itemsSelected` and
`rightSidePanel.missingModels.gatedModelsHint` came back from the model with CLDR-style
arity, and the PR normalises them back down to fit `pluralDefault`. That is a corpus
workaround for a missing runtime capability, and it has two costs:

1. The corpus is permanently shaped around the limitation. Every future translation run
must be arity-normalised by hand, forever.
2. Nothing enforces it. The pipeline's plural checks (`added plural separator`,
`empty plural form`) do not constrain form count, so a future run can reintroduce
4+ forms and silently mis-select.

No PR in the current stack (#15228, #15229, #15230, #15236) touches `src/i18n.ts`.

## Suggested fix

Register `pluralRules` for the locales whose CLDR category count exceeds what
`pluralDefault` can express — at minimum `ru` and `ar`, and check `pl`/`uk` if they are
ever added. Then either allow the corpus to carry true CLDR arity, or add a validator
that rejects form counts a registered rule cannot index.

## Verification

```
# form-count distribution per locale over English plural strings
git show :src/locales/ru/main.json # 26 three-form entries
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.