Skip to content
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

extract translates passed file with includes import react-native-qrcode-svg #1314

Closed
xrustic2020 opened this issue Dec 21, 2022 · 3 comments · Fixed by #1367
Closed

extract translates passed file with includes import react-native-qrcode-svg #1314

xrustic2020 opened this issue Dec 21, 2022 · 3 comments · Fixed by #1367

Comments

@xrustic2020
Copy link

Describe the bug
I`m trying run comand 'lingui extract --clean'
and getting to console this message:

"Cannot process file /Users/xrustic/projects/meg/app/mobile/source/cart/share-cart.screen.tsx: Cannot find module '/Users/xrustic/projects/meg/app/mobile/source/cart/react-native-qrcode-svg'
Require stack:

  • /.../node_modules/babel-plugin-transform-assets/lib/index.js
  • /.../node_modules/@babel/core/lib/config/files/module-types.js
  • /.../node_modules/@babel/core/lib/config/files/configuration.js
  • /.../node_modules/@babel/core/lib/config/files/index.js
  • /.../node_modules/@babel/core/lib/index.js
  • /.../node_modules/@lingui/cli/api/extractors/babel.js
  • /.../node_modules/@lingui/cli/api/extractors/index.js
  • /.../node_modules/@lingui/cli/api/catalog.js
  • /.../node_modules/@lingui/cli/lingui-extract.js
    Catalog statistics for /.../app/mobile/source/locales/{locale}/messages:
    ┌─────────────┬─────────────┬─────────┐
    │ Language │ Total count │ Missing │
    ├─────────────┼─────────────┼─────────┤
    │ ru (source) │ 745 │ - │
    │ uk │ 745 │ 0 │
    └─────────────┴─────────────┴─────────┘
    "

Finnaly extracted end successfull, but it's passed translates in file, who includes "import QRCode from 'react-native-qrcode-svg" (word and phrase in this file not extracted to .po file)

To Reproduce
create new react-native project with support Typescript:
"npx react-native init AwesomeTSProject --template react-native-template-typescript"

added next packages to "dependencies":

"@lingui/cli": "3.14.0",
"@lingui/macro": "3.14.0",
"@lingui/react": "3.14.0",
...
"react-native-qrcode-svg": "6.1.2",
...
"@babel/core": "7.15.0",

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

export default function App() {
   return <View><Trans>This should be translated!</Trans></View>
}

Expected behavior
Successfull extracted phrase in up example "This should be translated!" to .po file and don't get warning "Cannot process file..."

Additional context
This happens after install and implemented component from import "react-native-qrcode-svg"

What can i do for resolve this issues?

@timofei-iatsenko
Copy link
Collaborator

Please show your babel config.

Extractor uses babel with your project's configuration, so all plugins enabled in babel config would be applied in extraction process.

Generally babel is just a transpiler and not a code analyzer, so it should not resolve imports in the code (what is actually happened according to your stack trace)

So I assume you have some nonstandard plugin in babel config (babel-plugin-transform-assets ? ) which causes this issue.

@Martin005
Copy link
Contributor

@xrustic2020 Could you please post your babel config?
I tried reproducing your set-up (including using a component from "react-native-qrcode-svg"), but the extraction worked correctly.

@timofei-iatsenko
Copy link
Collaborator

Fixed in #1367 would be released as part of v4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants