Skip to content

Defining Custom React Components as a Wrapper for the Trans Macro #1728

Answered by thekip
torhector2 asked this question in Q&A
Discussion options

You must be logged in to vote

No, it's not possible and never would be. The extractor operates on AST, it doesn't execute your code. All your strings should be explicitly marked for extraction with either Trans, t, or any of i18n methods to be picked up by extractor.

So you library could be used only this way:

import { Heading } from '@chakra-ui/react';
import { Trans } from '@lingui/macro';

<Heading>
    <Trans>My message!</Trans> <!-- // Message declared in-place, and could be statically analyzed --> 
</Heading>

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by andrii-bodnar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants