-
Notifications
You must be signed in to change notification settings - Fork 390
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
Use lingui.js with multiple packages #1157
Comments
For now, we decided to use our own path. const options = {
en: { ...catalogEN.messages, ...EnglishMessages },
es: { ...catalogES.messages, ...EnglishMessages },
}
i18n.loadLocaleData(lang, {});
i18n.load(options);
i18n.activate(lang); So now we can use components from the UI package. |
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. |
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:
Any ideas? The best option I am thinking about is extracting strings for each project independently, then importing and merging |
I having the same issue and I'm interesting to know what would be your best practice on it. I guess it is not that easy to architecture that and I'm having the exact same questioning as @renchap
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Still actual? |
I would love to see this in progress. Is it possible? |
Ysss, I'll take care of this as soon as possible! |
I will add a bit from my experience. The built-in Angular i18n tooling solve this problem effectively. Instead of globbing folders, they wrote a plugin for bundler (webpack). It is webpack's responsibility to discover and parse all files used in the current application. So while webpack is bundling your actual application, plugin extract the messages from a code. Instead of manually pointing extractor to places where msgs potentially might be such as: monorepo/shared-ui1/src You point extractor to your entry points: monorepo/web-app1/src/main.ts Then extractor automatically (thanks to webpack) follow all imports and discover all files needed for extraction. This effectively solved the issue even with packages which are installed from npm. The drawbacks of this are slower extraction process and more complicated setup. The plus of it, you can use your existing webpack setup with all yours aliases/path mappings setup. After such extracting every app in monorepo would have it's own catalog of messages. The web app would not have messages from native and vice versa. Then localization platform will do the rest for you (reuse translation for the same keys) |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Up |
Why has this issue been closed? Nothing has been done yet and the latest status is that @semoal will work on it when he can. |
@thekip can this issue be resolved by the new experimental extractor feature? |
Yes. Attach it to here #1458 |
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 applicationpo
file also everything works good and component is translated. But after this i want to runlingui extract
for example because i added some another translation to app. Butmsgid
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
The text was updated successfully, but these errors were encountered: