How to combine all .po files into one en.po file with extract-experimental? #2312
-
I started using js-lingui in my react-native project. I followed the tutorial for react-native, I added a @lingui/metro-transformer plugin. I run lingui extract-experimental command, catalogs are created according to entries in config, for example: src/app/navigation/MainNavigator/BottomTabNavigator/i18n/en.po. lingui.config.js: export default defineConfig({
sourceLocale: 'en',
locales: ['en'],
catalogs: [],
experimental: {
extractor: {
entries: [
'src/shared/components/BottomSheets/*/index.tsx',
'src/app/navigation/MainNavigator/BottomTabNavigator/index.tsx',
'src/app/screens/*/index.tsx',
],
output: '<rootDir>/{entryDir}/i18n/{locale}',
},
},
catalogsMergePath: 'src/common/i18n/{locale}',
}); Code example: // it doesn't work.
// Cannot find module ./common/i18n/en.po because it doesn't exist
import { messages } from '../src/common/i18n/en.po';
i18n.loadAndActivate({ locale: 'en', messages }); In the code above I get an error that the file is not found. What needs to be done to combine all .po files into one en.po file? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Unfortunately |
Beta Was this translation helpful? Give feedback.
Ok let's take it one by one:
catalogsMergePath
works only forcompile
command, and it basically merge multiple catalogs defined in thecatalogs
into one per locale on the specified path. Loaders/transformers such as Metro transformer doesn't support this.<rootDir>/src/common/i18n/{locale}.js
pat…