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.

Use lingui.js with multiple packages

See original GitHub issue

Hey, four our frontend we are using monrepository architecture. We have split codebase per application and library (ui, utils…).

So, now we want to implement Lingui in our UI package. So we want prepare some React components separately with and then use this components in applications. It works well expect translations. We have installed Lingui in this packages and also works well. Its no problem to compile this library. Library is written in TypeScript and React.

But, after this i want use some component in application. If i paster msgid with translation directly into application po file also everything works good and component is translated. But after this i want to run lingui extract for example because i added some another translation to app. But msgid used in external component is not found and its marked as unused and commented.

I know Lingui searching components only in defined paths, but its possible to force Lingui to extract this translations from another package/node_modules folder etc?

Out current configuration

{
  "fallbackLocales": {
    "default": "en"
  },
  "sourceLocale": "en",
  "format": "po",
  "locales": ["en", "cs", "es"],
  "catalogs": [
    {
        path: "src/locales/{locale}/messages",
        include: [
            "<rootDir>/src/**/*"
        ]
    }
  ],
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
semoalcommented, Nov 26, 2021

This is something I want to explore for a long time, how Lingui works with monorepo of UI’s and how can these translations co-exist together. Will try to get some free time and create a repo where we can play and update Lingui to work nicely with monorepos.

2reactions
renchapcommented, Dec 10, 2021

I am having a similar issue: In a monorepo, I have both a web React app, a react-native mobile app, and a shared library with some common code.

I am not sure how to properly handle this, as:

  • we have many common strings between the web & mobile apps, so it would be great to only translate them once
  • we want to have some strings in the shared library translated
  • we do not want to ship mobile-only string into our web-app, and the other way around. Strings in the shared library should be in both

Any ideas?

The best option I am thinking about is extracting strings for each project independently, then importing and merging mobile/locale.js + ``shared/locale.jsin the mobile app, andweb/locale.js+shared/locale.jsin the web app, but strings need to be translated in each project independently as we get 3.po` files.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Migration guide from 2.x to 3.x — LinguiJS documentation
LinguiJS started as a React library. After @lingui/core package was introduced, there were two ways how to switch active locales and manage catalogs...
Read more >
How to set up internationalization in React using Lingui.js
Here's how to integrate Lingui.js with a React app and add internationalization capabilities to your application.
Read more >
@lingui/react - npm
React components for translations. Latest version: 3.15.0, last published: 2 months ago. Start using @lingui/react in your project by ...
Read more >
lingui/js-lingui - Gitter
i am trying to use it for a react native app. i followed the installation ... from multiple catalogs (e.g. chunks) and also...
Read more >
React App Internationalization With LinguiJS | by Artem Diashkin
js ; from lingui.config.ts _(since 3.4.0). In the case of TypeScript based configuration you can use ESM format ...
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