Skip to content
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

Macro docs lack of examples how to use plural() with custom i18n #1312

Open
thekip opened this issue Dec 16, 2022 · 0 comments
Open

Macro docs lack of examples how to use plural() with custom i18n #1312

thekip opened this issue Dec 16, 2022 · 0 comments

Comments

@thekip
Copy link
Collaborator

thekip commented Dec 16, 2022

https://lingui.js.org/ref/macro.html#plural

Documentation on this page shows how to use t`msg` with custom i18n instance. But lacking an example how to use plural() with it.

There is a note:

Use plural inside t macro if you want to add custom id or comment for translators.

But still not clear how to use it, and this note is quite hard to spot when you're reading docs roughly.

Which one would work:

import { plural } from "@lingui/macro"

const message = t(i18n)(plural(count, {
   one: `${name} has # friend`,
   other: `${name} has # friends`
}))

or

import { plural } from "@lingui/macro"

const message = t(i18n)({
  message: plural(count, {
   one: `${name} has # friend`,
   other: `${name} has # friends`
  })
})

or

import { plural } from "@lingui/macro"

const message = t(i18n)`${plural(count, {
   one: `${name} has # friend`,
   other: `${name} has # friends`
})}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants