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

feat: allow extract to work with i18n._ calls not created from macro #1309

Merged
merged 1 commit into from
Dec 8, 2022

Conversation

mitchjhill
Copy link
Contributor

This change updates babel-plugin-extract-messages so that it will pick up usages of the i18n._ method from @lingui/core directly.

This solves the issues mentioned in #1178 and #1224 (comment) without needing the workaround listed in 1178 (prefixing the id with /*i18n*/).

The main driver for this is to allow use of Lingui without macros, so that sites running on Next.js can use the SWC compiler instead of babel.

Aware that this is effectively adding back extract behavior that was removed previously, but hopefully this isn't too big of a deal - let me know if you have any feedback.

@vercel
Copy link

vercel bot commented Dec 6, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
js-lingui ❌ Failed (Inspect) Dec 6, 2022 at 0:17AM (UTC)

@semoal semoal merged commit 90be171 into lingui:main Dec 8, 2022
@mitchjhill mitchjhill deleted the feat/extract-i18n-without-macro branch December 9, 2022 16:03
@andrii-bodnar andrii-bodnar linked an issue Dec 29, 2022 that may be closed by this pull request
@capaj
Copy link
Contributor

capaj commented Mar 13, 2023

@mitchjhill just wanted to say

@timofei-iatsenko
Copy link
Collaborator

I would highly discourage you using this. Use macro whenever possible. If not possible, use https://formatjs.io/

PS Lingui already supports SWC https://github.com/lingui/swc-plugin

@capaj
Copy link
Contributor

capaj commented Mar 13, 2023

@thekip I had no idea about the SWC plugin! That looks gr8. Will try that out when I touch i18n next time.

@timofei-iatsenko
Copy link
Collaborator

why would you want to use lingui without a macro?

@capaj
Copy link
Contributor

capaj commented Mar 13, 2023

I want to use it on backend. Backend is plain typescript. We don't even run babel and we don't want to run babel.
We're sending quite a few push notifications from our BE. At the moment it's just maybe 70 strings, but it will be more in the future.

@capaj
Copy link
Contributor

capaj commented Mar 13, 2023

I just tried running SWC and that does not work for us, because SWC handles decorators a bit differently.

@timofei-iatsenko
Copy link
Collaborator

I just tried running SWC and that does not work for us, because SWC handles decorators a bit differently.

Probably related: nestjs/graphql#2568

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lingui extract doesn't handle i18n._ strings
4 participants