-
Notifications
You must be signed in to change notification settings - Fork 386
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
Not extracted messages get replaced with generated ids in the production build #1803
Comments
@krzkaczor hey, this is intentional design decision. During development (NODE_ENV==development) default messages included in bundle with a compiler. But for production build all non-essential properties and message compiler dropped. There is literally nothing to fallback to in production build. The good solution would be to add an extract step just before running a production build in your CI pipeline. Extract to template creating a "template" which you can then add to git ignore because it's an artifact produced from your code, such as sourcemaps. All cli tooling is aware of templates and will use it to fallback in case of message not found in original catalog. I also recommend to use vite loader or webpack loader for catalogs to avoid explicit compilation step. So full solution would be:
Note: As you see i also recommend to use Po format. I know that many developers in the beginning deciding to go with JSON because they think it would be easier to start with. But there are no advantages of json over PO files, because both of them you need to compile before use, but PO file will provide way better developer and translation experience than json. |
@thekip Thank you for this detailed explanation. Helps a lot.
It would be great to mention this somewhere in the docs. |
Describe the bug
Not extracted messages get replaced with generated ids (ex.
c1GOrp
) but only in production builds.To Reproduce
My
lingui.config.ts
:I can provide full repro code but it seems like I am obviously missing something.
Expected behavior
It should fallback to a string used in code == same behaviour as in dev mode.
Additional context
I would appreciate any guidance. Should we bail our CI if we detect that a developer forgot to run message extraction? should we maybe run extraction just before
vite build
to deal with untranslated strings automatically? Context: the app is under heavy development and missing translations are not a problem for us now.I already played with fallback located and source locale but nothing seems to work. I am feeling like I am missing something obvious.
4.5.0
npm list @babel/core
@lingui/swc-plugin
babel-macro-plugin
.babelrc
) or framework you use (Create React App, NextJs, Vite): VITEvite.config.ts:
The text was updated successfully, but these errors were encountered: