i18next / i18next-icu

i18nFormat plugin to use ICU format with i18next
MIT License
81 stars 17 forks source link

Plural and number format combination #65

Closed felicoz closed 1 year ago

felicoz commented 1 year ago

Hi, I have search through the google and github and no luck with a solution so I start an thread to ask.

Shop {numOfItems, plural, =1 {1 Item} other {# Items}}

My goal is to have number and plural formation together from a key: English: Shop 10,000 Items French: Shop 10 000 Items

But I am getting the following at the moment: English: Shop 10,000 Items French: Shop 10,000 Items

Is that possible? currently seems like I can only do either number or plural or currency separately.

"i18next": "^20.3.5",
"i18next-browser-languagedetector": "^6.1.3",
"i18next-chained-backend": "^4.2.0",
"i18next-http-backend": "^2.2.1",
"i18next-icu": "^2.0.3",
"i18next-localstorage-backend": "^4.1.1",
"next-i18next": "^12.1.0",

If I try to localize the number myself, the final result becomes a string "10,000" and won't be able use the ICU plural format.

thanks!

adrai commented 1 year ago

Seems to work as expected: https://codesandbox.io/s/friendly-joana-s7mdv7?file=/src/index.mjs

image

https://format-message.github.io/icu-message-format-for-translators/editor.html

image
felicoz commented 1 year ago

oops my bad, it does work...