Replies: 1 comment 2 replies
-
You also can use <Trans>
The price is: {i18n.number(price, { style: "currency", currency: "EUR" })}
</Tans> This will use number formatting rules from current locale + styling option for this currency. Examples from test suite: it("should pass format options", () => {
expect(
number(["en"], 1000, { style: "currency", currency: "EUR" })
).toMatchInlineSnapshot(`"€1,000.00"`)
expect(
number(["en"], 1000, { maximumSignificantDigits: 3 })
).toMatchInlineSnapshot(`"1,000"`)
})
it("should respect passed locale", () => {
expect(
number(["pl"], 1000, { style: "currency", currency: "EUR" })
).toMatchInlineSnapshot(`"1000,00 €"`)
}) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a requirement to translate something like this:
But for some other currencies such as Chinese yuan it may be
{price} 元
.I am thinking maybe I can do something like
<Trans render=() => { return <>JPY ¥ {price} </>}></Trans>
and then pass the price variable into the Trans tag. But I am not sure how to change the texts in translations. Maybe I need to use the value prop?Is there a better way to do it in Lingui?
EDIT:
I just figured out I can just use
<Trans>JPY ¥ {price}</Trans>
. The Trans tag can convert the variable correctly.Beta Was this translation helpful? Give feedback.
All reactions