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

[Translation Module] Extract Message is not working properly #102

Closed
safranx opened this issue Dec 23, 2020 · 3 comments
Closed

[Translation Module] Extract Message is not working properly #102

safranx opened this issue Dec 23, 2020 · 3 comments

Comments

@safranx
Copy link

safranx commented Dec 23, 2020

Before opening a new issue, please take a moment to review our community guidelines to make the contribution process easy and effective for everyone involved.

Description

I tried to add new translations, to a generated component but I am getting an error:

TypeError: Cannot readt property 'whatever' of undefined

Steps to reproduce

Steps to reproduce the behavior:

> npx create-react-app --template cra-template-rb my-app
> cd my-app
> yarn run cleanAndSetup
> yarn generate component Footer

Adding a new translation entry to messages.ts (in the new build component (Footer))
Extracting messages to generate the new entry in translation.json files: yarn run extract-messages.

QUICK FIX

You have to edit the function isImportedTranslationObject(content, key).
In internals\extractMessages\stringfyTranslations.js remplace +locales/i18n.* by +locales/translations.*

function isImportedTranslationObject(content, key) {
  const pattern = `import {.*?${key}.*?} from.+locales/translations.*`;
  return RegExp(pattern, 'gim').test(content);
}

Versions

  • react-boilerplate-cra-template: v1.1.1
  • Node/NPM: v14.15.1
  • Browser: Version 1.18.75 Chromium: 87.0.4280.101 (Official Build) (64 bits)
@safranx safranx changed the title [i18next] Translations: Cannot read property of undefined [i18next] Translations: Cannot read property [WHATEVER] of undefined Dec 23, 2020
@safranx safranx changed the title [i18next] Translations: Cannot read property [WHATEVER] of undefined [i18next] Translations: Cannot read property [whatever] of undefined Dec 23, 2020
@safranx safranx changed the title [i18next] Translations: Cannot read property [whatever] of undefined [i18next] Translations tree issue with and without extracting messages. Dec 23, 2020
@safranx safranx changed the title [i18next] Translations tree issue with and without extracting messages. [Translation Module] isImportedTranslationObject(content, key) Issue. Dec 24, 2020
@safranx safranx changed the title [Translation Module] isImportedTranslationObject(content, key) Issue. [Translation Module] Extract Message is not working properly Dec 24, 2020
@Can-Sahin
Copy link
Member

Good catch. Thanks

@Can-Sahin
Copy link
Member

Fixed with 4b8788c

@safranx
Copy link
Author

safranx commented Dec 31, 2020

Translations aren't working properly if the component or container isn't import with his "optional" Loadable.ts.

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

No branches or pull requests

2 participants