lingui / js-lingui

🌍 📖 A readable, automated, and optimized (3 kb) internationalization for JavaScript
https://lingui.dev
MIT License
4.45k stars 376 forks source link

JSX macros aren't working inside JSX expressions in JSX macros #1175

Closed khmm12 closed 1 year ago

khmm12 commented 2 years ago

Describe the bug

Since v3 JSX macros aren't working inside JSX expressions in JSX macros. v2 macros are working as expected.

The issue is reproducible in any nesting level.

To Reproduce

import { Trans } from '@lingui/macro'

export default function Component(props) {
  return <Trans>Hello, {props.world ? <Trans>world</Trans> : <Trans>guys</Trans>}</Trans>
}

Expected behaviour

import { Trans } from '@lingui/react'

export default function Component(props) {
  return (
    <Trans
      id='Hello, {0}'
      values={{
        0: props.world ? <Trans id='world' /> : <Trans id='guys' />
      }}
    />
  )
}

Actual behaviour

import { Trans } from '@lingui/react'

export default function Component(props) {
  return (
    <Trans
      id='Hello, {0}'
      values={{
        0: props.world ? <Trans>world</Trans> : <Trans>guys</Trans>
      }}
    />
  )
}

Additional context

semoal commented 2 years ago

Thx @khmm12 will take a look as soon as possible. Indeed looks a regression

tulodzieckim-simplito commented 2 years ago

Any news about this?

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

khmm12 commented 2 years ago

No, still actual.

khmm12 commented 2 years ago

Up

thekip commented 1 year ago

If some one takes this task, please, also check that in the SWC plugin. The test case should ported there.

thekip commented 1 year ago

Checked this in SWC, this also don't work. I made a quick fix for 1 level of nesting for js macro. But if there would be more levels, that would break again. To fix this, fundamental changes needed. Still think how to do that.

thekip commented 1 year ago

fixed by https://github.com/lingui/js-lingui/pull/1436 and would be released with v4