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

Lingui doesn't extract msg within a msg #1841

Closed
joeldouglass opened this issue Jan 22, 2024 · 2 comments
Closed

Lingui doesn't extract msg within a msg #1841

joeldouglass opened this issue Jan 22, 2024 · 2 comments

Comments

@joeldouglass
Copy link

In a case where we might have a msg within a msg, Lingui skips the inner msg leading to a ReferenceError: msg is not defined at runtime.

Ex:

<SomeComponent title={_(msg`Foo ${someFlag ? _(msg`bar`) : _(msg`baz`)}`)} />

Maybe there's a better way to do this?

@joeldouglass joeldouglass changed the title Lingui doesn't extract msg with a msg Lingui doesn't extract msg within a msg Jan 22, 2024
@thekip
Copy link
Collaborator

thekip commented Jan 23, 2024

As far as i remember i fixed something like that for babel version of macros, but this still an issue in SWC.

lingui/swc-plugin#16
#1436

These two issues about JSX ternary but it seems it's also applicable for JS ternary.

The workaround would be just avoiding putting ternary into the msg:

const innerMessage = ${someFlag ? _(msg`bar`) : _(msg`baz`)}
<SomeComponent title={_(msg`Foo ${innerMessage}`)} />

@thekip
Copy link
Collaborator

thekip commented Mar 5, 2024

Should be fixed for babel macro with #1867

@thekip thekip closed this as completed Mar 5, 2024
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

2 participants