question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@lingui/babel-preset-react is probably missing in babel config

See original GitHub issue

Describe 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

  1. Fork https://github.com/facebook/create-react-app
  2. Make app
  3. Follow https://lingui.js.org/tutorials/react.html#installing-linguijs

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.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:18 (13 by maintainers)

github_iconTop GitHub Comments

4reactions
tricoder42commented, Oct 7, 2018

That means there should be all these functions/components exported from a package with prebaked i18n instance and you should be able to change its configuration instead of making a new one.

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:


import i18n, { Trans } from `@lingui/macro`

<a title={i18n.t`Link title`}><Trans>Content</Trans></a>

this would be transformed to:

import i18n, { Trans } from `@lingui/react`

<a title={i18n._('Link title' )}><Trans id="Content" /></a>

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.

3reactions
MartijnHolscommented, Oct 5, 2018

Oh my god, it’s so simple! 😊 Thanks, I’ll try it tonight but it makes total sense.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found