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

fix: unable extract translation messages #1646

Conversation

vinhtrinh
Copy link

Description

There are some issues in the translation messages extraction

  1. Use expressions within regular strings
  2. formatjs extract command is failing when a large number of override files are present, exceeding the maximum allowed command length.
  3. Ineffective file ignoring using absolute paths
    • The --ignore option is designed to accept glob patterns. By using a list of absolute file paths will not matching any files. Thereforce, no files being ignored.

Types of Changes

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Documentation update
  • Breaking change (could cause existing functionality to not work as expected)
  • Other changes (non-breaking changes that does not fit any of the above)

Changes

  • Change regular strings which contains expressions to literal strings
  • Remove --ignore option from the command
    • The order of file patterns to extract the messages are matter. By load after extends packages, messages in the overrides folder take precedence over existing keys from other packages.
    • ** However, messages unused in the overridden components will remain. This behavior is same as how SFCC merge properties files accross multiple cartridges and can be an acceptable behavior.

If we look at the implementation history, there's a solution that renames overridden files to {filename}.ignore before running the extract command. This is a great idea in principle, but it can lead to unexpected issues if:

  • The files are renamed to .ignore and an error occurs during execute the command (e.g., I/O exceptions, extraction failure, etc.)
  • This error prevents the script restore the files to their original names.

In these cases, developers might be left completely puzzled about why a file in node_modules is missing. Debugging this issue could take a whole day and might only be resolved by deleting the node_modules folder and reinstalling dependencies.

Checklists

General

  • Changes are covered by test cases
  • CHANGELOG.md updated with a short description of changes (not required for documentation updates)

Accessibility Compliance

  • There are no changes to UI

Localization

  • Changes include a UI text update in the Retail React App (which requires translation)

Close #1645

@vinhtrinh vinhtrinh requested a review from a team as a code owner January 23, 2024 14:58
@vinhtrinh vinhtrinh closed this Jan 25, 2024
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

Successfully merging this pull request may close these issues.

[BUG] Unable to extract the translations
1 participant