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

Improve error logging during apps build for I18n content #44949

Merged
merged 2 commits into from
Mar 2, 2022

Conversation

daynew
Copy link
Member

@daynew daynew commented Feb 21, 2022

When we run yarn build or yarn start, it will look for i18n JSON files owned by the apps project and parse the content using the MessageFormat library. If the content fails to be parsed, the build is failed and an error is logged. There are two improvements we make to this process in this PR:

  • Checks for MessageFormat syntax errors one string at a time so we can produce an error for the exact string which is failing. Currently it will just log something like "Failed to parse string in ar_sa/maze.json" which isn't helpful enough because there are thousands of strings in that file.
  • Check all i18n content before producing an error summary. Currently the build process reports only the first error it runs into. Usually when we run into these issues is after we have downloaded thousands of new translations from Crowdin. Usually there are many strings which need to be addressed and it is slow/tedious to rerun the build after each string fix.

Links

Testing story

  • Manually tested
    I manually created some errors in our JSON files and this was the output of yarn build
Running "messages:all" (messages) task
Warning: All I18n content issues:
Error: key 'danceFeedbackNeedNewDancer' in localization file i18n/dance/ca_es.json has a format issue: SyntaxError: Expected "," or "}" but "d" found.
Error: key 'fishshort-predicting-init1' in localization file i18n/fish/ar_sa.json has a format issue: SyntaxError: Expected "#", "{", doubled apostrophe, end of input, escaped string, or plain char but "}" found.
Error: key 'cancel' in localization file i18n/fish/bn_bd.json has a format issue: SyntaxError: Expected "," or "}" but "ক" found.
Error: key 'continue' in localization file i18n/fish/fi_fi.json has a format issue: SyntaxError: Expected "," or "}" but "J" found. Use --force to continue.

@daynew daynew force-pushed the better-i18n-json-error-logging branch from 7a12ff0 to d6fe838 Compare March 2, 2022 20:43
@daynew daynew changed the title Hacky improvement for i18n JSON parsing error logging Improve error logging during apps build for I18n content Mar 2, 2022
@daynew daynew requested a review from a team March 2, 2022 21:48
@daynew daynew marked this pull request as ready for review March 2, 2022 21:48
Copy link
Contributor

@annaxuphoto annaxuphoto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

apps/tasks/messages.js Outdated Show resolved Hide resolved
@daynew daynew merged commit 88453af into staging Mar 2, 2022
@daynew daynew deleted the better-i18n-json-error-logging branch March 2, 2022 22:35
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.

None yet

2 participants