js-lingui icon indicating copy to clipboard operation
js-lingui copied to clipboard

@lingui/core i18n._(/* i18n */ `Sign in`) when running lingui extract isn't picked up

Open paales opened this issue 3 years ago • 2 comments

Describe the bug

We're not using the @lingui/macro and are using bare @lingui/core and @lingui/react. We're using it in combination with nextjs.

To handle string translations we use i18n directly (for example for

fields, etc.): <pre><code>i18n._(/* i18n */ `Sign in`) </code></pre> <p>However, when running lingui extract it doesn't pick up the translations.. It used to work, but somewhere in the last few months it stopped working.</p> <p>It seems that it has to do with the backticks, if I replace it with regular quotes, it does work:</p> <pre><code>i18n._(/* i18n */ 'Sign in') </code></pre> <p><strong>To Reproduce</strong> Create a translation with backticks like so:</p> <pre><code>i18n._(/* i18n */ `Sign in`) </code></pre> <p><strong>Expected behavior</strong></p> <p>I would expect backticks to work.</p> <p><strong>Additional context</strong></p> <p>I've replaced all backticks with regular quotes, so that solves the issue for us for now :)</p>

paales avatar Jun 28 '22 13:06 paales

Will take a look to everything you opened mate asap, before the end of this week it will be solved. Srry for the inconveniences.

semoal avatar Jun 28 '22 19:06 semoal

@semoal We've got workarounds in place, so no rush :)

paales avatar Jun 28 '22 22:06 paales

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.

stale[bot] avatar Sep 08 '22 22:09 stale[bot]

Not stale

paales avatar Sep 13 '22 15:09 paales

Hello @paales! Do you remember which version of lingui packages you used? I tried the following version but the extraction worked:

  • [x] 3.15.0
  • [x] 3.14.0
  • [X] 3.13.3
  • [X] 3.13.2
  • [X] 3.13.1
  • [X] 3.13.0
  • [X] 3.12.1

BUT I found that we are not putting the line number to the PO file if you use backticks ` in the i18n._() call.

{i18n._(/* i18n */ `Home`)}
{i18n._(/* i18n */ "Account")}

outputs

#: src/App.tsx:9
msgid "Account"
msgstr "Account"

#: src/App.tsx:
msgid "Home"
msgstr "Home"

This maybe relates to your issue 🙂 Were you pre-processing or post-processing the output files?

Martin005 avatar Jan 13 '23 17:01 Martin005