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.

No messages extracted outside of react

See original GitHub issue

No messages get extracted when using:

import i18n from './utils/i18n'
import {t} from '@lingui/macro';

i18n._(t`hello`)

They get extracted when using it like:

i18n._("hello")

They also get extracted as expected when using a react component:

import {Trans} from '@lingui/react';

<Trans>Hello</Trans>

any ideas?

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
semoalcommented, Nov 5, 2020

That’s great. How does it work with shared components libraries that contain catalogs?

In our case we have

  • ui-1 - catalog-ui-1
  • ui-2 - catalog-ui-2
  • shared-components - catalog-shared-components

There are going to be different instances / catalogs. How do these get reconciled?

They get merged by locale internally, you have more information in lingui website on configuration section.

Tomorrow I’ll expand this a lit

2reactions
diegolacartacommented, Dec 13, 2018

I just tried changing my .linguirc to:

{
   "localeDir": "src/locales/",
   "srcPathDirs": ["src/"],
   "format": "po",
   "extractBabelOptions": {
      "plugins": ["@babel/plugin-syntax-dynamic-import", "macros"]
   }
}

Adding “macros” it now extracts the message with both <Trans/> from marcos, and i18n._(t`…`), but doesn’t translate it

Read more comments on GitHub >

github_iconTop Results From Across the Web

No messages returned when running formatjs extract on ...
Now, whenever I run the script for extraction ( messages:extract ) all I get is an empty json object. Any ideas if I'm...
Read more >
Internationalize your React App In 5 Easy Steps With React Intl
Use the <FormattedMessage> component with the ID of the internationalized message to get the message based on the currently selected locale; Run ...
Read more >
Internationalize your React App with React Intl - bene : studio
The purpose of extracting messages is to make the development faster and increase the readability of the code. It will be faster because...
Read more >
Testing Recipes - React
Testing Recipes. Common testing patterns for React components. Note: This page assumes you're using Jest as a test runner.
Read more >
React internationalization with react-intl - Localizely
Message extraction. While it is good to start with internationalization from the very beginning of the app development, it is not always ...
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