ttag-org / ttag

:orange_book: simple approach for javascript localization
https://ttag.js.org/
MIT License
345 stars 43 forks source link

translations inside jt are not extracted #179

Open AlexMost opened 5 years ago

AlexMost commented 5 years ago

Example:

<div>{jt`${ <strong>${ jt`oh no` }</strong>} you did something wrong`}</div>

ttag update will not extract oh no

https://github.com/ttag-org/ttag/issues/177#issuecomment-517524467

abidjappie commented 9 months ago

I attempted to recreate an analogy of this issue in the test suite. I know the JSX is slightly different, but I think the conclusion might be similar:

// Analogy test case
const strong = '<Strong>';
expect(jt`${strong + `${jt`oh no`}` + strong} you did something wrong`)

This is broken down using buildArr with the following args:

Strs [ '', ' you did something wrong' ]
Exprs [ '<Strong>oh no<Strong>' ]

and results in:

      -[
      -  ""
      -  "<Strong>oh no<Strong>"
      -  " you did something wrong"
      -]

The problem is because the first tagged templates return value is used directly in the final output of the jt. I'm not sure if there's anyway to fix this right now, just wanted to post my findings.

Please let me know if I'm looking in the wrong place, I'd like to help out if I can! EDIT: I should probably investigate inside the getMsgid 🙇