@lingui/babel-preset-react is probably missing in babel config
See original GitHub issueDescribe the bug
<Trans>
elements don’t show in dev- Console prints:
@lingui/babel-preset-react is probably missing in babel config, but you are using <Trans> component in a way which requires it. Either don't use children in <Trans> component or configure babel to load @lingui/babel-preset-react preset. See tutorial for more info: https://l.lingui.io/tutorial-i18n-react
- The link in the console message doesn’t point to a tutorial
- Production crashes
To Reproduce
- Fork https://github.com/facebook/create-react-app
- Make app
- Follow https://lingui.js.org/tutorials/react.html#installing-linguijs
- Install cli locally so managing its version across developers is much easier
- find that
babel-plugin-macros
is already enabled in the config: https://github.com/WoWAnalyzer/create-react-app/blob/wowanalyzer-2.0/packages/babel-preset-react-app/create.js#L109
Expected behavior
- I’d expect it to work without
@lingui/babel-preset-react
since it’s not mentioned in the docs - The link to point to a tutorial
Additional context Add any other context about the problem here.
- jsLingui version
lingui --version
2.7.0 - Babel version
npm list babel-core
babel-core@7.0.0-bridge.0 - Your Babel config (e.g.
.babelrc
) or framework you use (Create React App, Meteor, etc.) https://github.com/WoWAnalyzer/create-react-app/blob/wowanalyzer-2.0/packages/babel-preset-react-app/create.js (CRA 2.0 with minor changes)
Issue Analytics
- State:
- Created 5 years ago
- Comments:18 (13 by maintainers)
Top Results From Across the Web
@lingui/babel-preset-react - npm
Start using @lingui/babel-preset-react in your project by running `npm i @lingui/babel-preset-react`. There are 9 other projects in the npm ...
Read more >lingui/js-lingui - Gitter
I just created a new React-Native app using init and then installed Lingui v2.91 and it all works, including <I18n> tags and the...
Read more >Parsing error: Cannot find module '@babel/preset-react'
I happened to have VSCode opened in a fullstack project where front and back were sepparate folders. When I opened VSCode only in...
Read more >@lingui/babel-preset-react | Yarn - Package Manager
Babel preset for all Lingui plugins required in React apps (for vanilla JS apps see ... add null undefined check (016ff0e); allow lingui...
Read more >The complete guide to internationalization in Next.js
npm install --save-dev @lingui/cli @lingui/loader @lingui/macro babel-plugin-macros @babel/core npm install --save @lingui/react make-plural ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It used to be like that in early version of LinguiJS but I was afraid that having a global/default i18n instance would lead to errors.
Still, no way to get rid of two imports (runtime vs macro), because macros must be imported from specific module name. At least we could get
i18n.t
syntax back:this would be transformed to:
This is trivial example to keep things simple. We could rename runtime/macro exports to make it clear what is what…
If you want to use a custom instance of
i18n
, then you need to create your own./i18n.macro.js
file as described above.Oh my god, it’s so simple! 😊 Thanks, I’ll try it tonight but it makes total sense.