lingui / js-lingui

🌍 📖 A readable, automated, and optimized (3 kb) internationalization for JavaScript
https://lingui.dev
MIT License
4.48k stars 377 forks source link

Plural translation not working with React and po file #456

Closed ghost closed 3 years ago

ghost commented 5 years ago

Describe the bug

I am not able to translate text using Plural component.

To Reproduce

Plural component (from "@lingui/react") is used as this :

<Plural
        value={maxLength - value.length}
        _0="Maximum characters reached"
        one="# character remaining"
        other="# characters remaining"
      />

And the po file using lingui extract looks like this :

#: src/components/CharacterController/CharacterController.tsx:5
msgid "{0, plural, =0 {Maximum characters reached} one {# character remaining} other {# characters remaining}}"
msgstr ""

So I would expect translation to work if I complete it this way :

#: src/components/CharacterController/CharacterController.tsx:5
msgid "{0, plural, =0 {Maximum characters reached} one {# character remaining} other {# characters remaining}}"
msgstr "{0, plural, =0 {Taille maximum atteinte} one {# caracère restant} other {# caractères restants}}"

Expected behavior I would expect my text to be properly translated in french.

Additional context

Hotell commented 5 years ago

I was facing similar issues although with Plural from @lingui/macro 👉 https://github.com/lingui/js-lingui/issues/415#issuecomment-505874642

Make sure you have @lingui/babel-preset-react installed and set within presets within your babel config. That solved my problem

tricoder42 commented 3 years ago

Hey @ghostd, new version 3.x was published recently. Please check if you problem persist in the new version and feel free open new issue with updated example.