Replies: 1 comment 7 replies
-
But what you expecting in outermost Trans? If you don't have any text to translate there it would be empty. Look at the test case to understand how macro transform your code: {
name: "JSX Macro inside JSX conditional expressions",
stripId: true,
input: `
import { Trans } from '@lingui/macro';
<Trans>Hello, {props.world ? <Trans>world</Trans> : <Trans>guys</Trans>}</Trans>
`,
expected: `
import { Trans } from '@lingui/react';
<Trans
id={'<stripped>'}
message={"Hello, {0}"}
values={{
0: props.world ? <Trans id={"<stripped>"} message={'world'} /> : <Trans id={'<stripped>'} message={'guys'} />
}}
/>
`,
}, In catalog in this case you will get 3 messages:
If you don't want to split your message into chunks you can use Select format like so import {Select} from "@lingui/macro"
<Trans>Hello, <Select value="props.world ? 'world' : 'guys'" _world="World" _guys="Guys" /></Trans> In catalog you receive
For ternary you can use |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have tried following this PR:
#1436
<Trans>{isA? <Trans id="a">A</Trans> : isB ? <Trans id="b">B</Trans> : <Trans id="c">C</Trans>}</Trans>
But it only generates translations with the same text as the id of the
Trans
tagI got the same result with or without the outermost
Trans
tagBeta Was this translation helpful? Give feedback.
All reactions