formatjs icon indicating copy to clipboard operation
formatjs copied to clipboard

Feature request for eslint-plugin-formatjs: lint rule to require placeholders for numbers in all branches of ICU plurals

Open dgoldstein0 opened this issue 1 year ago • 2 comments

Today, a lot of engineers I work with will write ICU strings like {numThings, plural, one{1 thing}, other{# things}}. The lack of a placeholder in the one case 1 thing causes problems downstream for our localization team, as the translation platform only lets the translators use the placeholders which are present in the source string. Slavic languages like Russian and Polish, unlike English, reuse the "one" form of the plural for multiple numbers - in Russian, the one form is also used for 21, 31, 41 - etc - so when they are translating the one form, they need the placeholder in the original string. So the original string should be {numThings, plural, one{# thing}, other{# things}}; other variants like {numThings, plural, one{{numThings} thing}, other{{numThings} things}} would also be acceptable.

A lint rule should be able to catch this, and ideally recommend an autofix.

dgoldstein0 avatar Jul 23 '24 18:07 dgoldstein0

yeah that shouldn't be too bad

longlho avatar Aug 02 '24 03:08 longlho

@longlho I've already have this eslint rule in-house, will push a fix upstream

cungminh2710 avatar Aug 15 '24 12:08 cungminh2710

@longlho I've pushed the rule as a pull request. Can you please review that whenever possible? 🙏

cungminh2710 avatar Aug 30 '24 02:08 cungminh2710

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Sep 30 '24 02:09 github-actions[bot]

I believe there is in progress work for this. The request still remains valid either way

On Sun, Sep 29, 2024, 7:03 PM github-actions[bot] @.***> wrote:

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

— Reply to this email directly, view it on GitHub https://github.com/formatjs/formatjs/issues/4478#issuecomment-2381863248, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIGO53JIGWDKXGYT2ZTPJDZZCWPLAVCNFSM6AAAAABLK5TLIWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOBRHA3DGMRUHA . You are receiving this because you authored the thread.Message ID: @.***>

dgoldstein0 avatar Sep 30 '24 22:09 dgoldstein0

solved by 0fa83d47efc04e65acacb6cad8fc585b8882a77f (implemented in #4500)

dgoldstein0 avatar Oct 11 '24 05:10 dgoldstein0