-
Notifications
You must be signed in to change notification settings - Fork 385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
plural not working the way documentation is describing it #2074
Comments
Could you point where you find your first example in the documentation? Your approach with direct usage of ICU will also work if you want to define plural message for later use. |
Ok thanks for the clarification. It would be great to have |
There is a hacky way to use plural to define message for the later use: // define fake variable for placeholder
const count = 0;
const messages = {
'testPlural': msg`${plural(count, {
one: '# friend',
other: '# friends',
})}`
}
const MyComponent = () => {
const { t } = useLingui();
const friendCount = 18;
const translatedMessage = i18n.t(messages.testPlural.id, {count: friendCount})
} For sure for future that should be improved. I think the only "good" way for now, it what is you already done with a ICU |
I tried your suggestion importing I found the example on my first message with Claude, but he was only able to tell me to use raw ICU message instead. It will be easier for me to use that instead. |
I believe this issue was fixed in the eslint plugin, try to update to the latest version. If it's still giving this false-positive, open an issue in that repo https://github.com/lingui/eslint-plugin |
I already had the |
Describe the bug
plural
is not working the way we would expect when reading the documentation. We cannot create plural messages based onplural
, where we inject the value later.To Reproduce
❌ Failing implementation:
message
is looking like that (with values inside):Expected behavior
✅ Working implementation
message
is looking like that:Additional context
plural
should help us create easily plural forms of messages, which is not the case currently.4.13.0
4.0.9
@lingui/swc-plugin
babel-macro-plugin
The text was updated successfully, but these errors were encountered: