i18n_compile Fails with TypeError: Cannot read properties of undefined (reading 'length') due to undefined message

Open
#3,837 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
javascript

Research direction

Start with the npm run i18n_compile command and inspect src/i18n/messages, especially the locale files named in the warnings and the dropzone.Dropzone.invalidSizeLessError entry. Verify the translation data for that ID and rerun the compilation; done means the warnings and TypeError no longer occur.

Written by the indexing model from the issue text.

Description

Description

The npm run i18n_compile script, which uses formatjs compile-folder, is failing with a TypeError when attempting to compile the translation messages.

This appears to be caused by an undefined translation message for the ID "dropzone.Dropzone.invalidSizeLessError" across multiple language files. The @formatjs/cli tool is issuing a series of warning messages indicating the validation error before the final crash:

Branch: release-23.x

➜  paragon git:(742704416d) npm run i18n_compile

> @openedx/paragon@20.18.1 i18n_compile
> formatjs compile-folder --format transifex ./src/i18n/messages ./src/i18n/messages

[@formatjs/cli] [WARN] Error validating message "undefined" with ID "dropzone.Dropzone.invalidSizeLessError" in file "./src/i18n/messages/es_AR.json"
[@formatjs/cli] [WARN] Error validating message "undefined" with ID "dropzone.Dropzone.invalidSizeLessError" in file "./src/i18n/messages/ar.json"
[@formatjs/cli] [WARN] Error validating message "undefined" with ID "dropzone.Dropzone.invalidSizeLessError" in file "./src/i18n/messages/fr.json"
[@formatjs/cli] [WARN] Error validating message "undefined" with ID "dropzone.Dropzone.invalidSizeLessError" in file "./src/i18n/messages/he.json"
[@formatjs/cli] [WARN] Error validating message "undefined" with ID "dropzone.Dropzone.invalidSizeLessError" in file "./src/i18n/messages/es_419.json"
[@formatjs/cli] [WARN] Error validating message "undefined" with ID "dropzone.Dropzone.invalidSizeLessError" in file "./src/i18n/messages/ca.json"
[@formatjs/cli] [WARN] Error validating message "undefined" with ID "dropzone.Dropzone.invalidSizeLessError" in file "./src/i18n/messages/ko_KR.json"
[@formatjs/cli] [WARN] Error validating message "undefined" with ID "dropzone.Dropzone.invalidSizeLessError" in file "./src/i18n/messages/es_ES.json"
[@formatjs/cli] [WARN] Error validating message "undefined" with ID "dropzone.Dropzone.invalidSizeLessError" in file "./src/i18n/messages/id.json"
[@formatjs/cli] [WARN] Error validating message "undefined" with ID "dropzone.Dropzone.invalidSizeLessError" in file "./src/i18n/messages/it_IT.json"
[@formatjs/cli] [WARN] Error validating message "undefined" with ID "dropzone.Dropzone.invalidSizeLessError" in file "./src/i18n/messages/pt_BR.json"
[@formatjs/cli] [WARN] Error validating message "undefined" with ID "dropzone.Dropzone.invalidSizeLessError" in file "./src/i18n/messages/pl.json"
[@formatjs/cli] [WARN] Error validating message "undefined" with ID "dropzone.Dropzone.invalidSizeLessError" in file "./src/i18n/messages/ru.json"
[@formatjs/cli] [WARN] Error validating message "undefined" with ID "dropzone.Dropzone.invalidSizeLessError" in file "./src/i18n/messages/pt_PT.json"
[@formatjs/cli] [WARN] Error validating message "undefined" with ID "dropzone.Dropzone.invalidSizeLessError" in file "./src/i18n/messages/th.json"
[@formatjs/cli] [WARN] Error validating message "undefined" with ID "dropzone.Dropzone.invalidSizeLessError" in file "./src/i18n/messages/uk.json"
[@formatjs/cli] [WARN] Error validating message "undefined" with ID "dropzone.Dropzone.invalidSizeLessError" in file "./src/i18n/messages/tr_TR.json"
[@formatjs/cli] [WARN] Error validating message "undefined" with ID "dropzone.Dropzone.invalidSizeLessError" in file "./src/i18n/messages/zh_CN.json"
TypeError: Cannot read properties of undefined (reading 'length')
    at Parser2.isEOF (/Users/peterkulko/dev/paragon/node_modules/@formatjs/cli/bin/formatjs:157458:47)
    at Parser2.parseMessage (/Users/peterkulko/dev/paragon/node_modules/@formatjs/cli/bin/formatjs:156929:22)
    at Parser2.parse (/Users/peterkulko/dev/paragon/node_modules/@formatjs/cli/bin/formatjs:156925:21)
    at parse5 (/Users/peterkulko/dev/paragon/node_modules/@formatjs/cli/bin/formatjs:157608:55)
    at compile7 (/Users/peterkulko/dev/paragon/node_modules/@formatjs/cli/bin/formatjs:159258:67)
    at async Promise.all (index 3)
    at async compileFolder (/Users/peterkulko/dev/paragon/node_modules/@formatjs/cli/bin/formatjs:159319:19)
    at async Command.<anonymous> (/Users/peterkulko/dev/paragon/node_modules/@formatjs/cli/bin/formatjs:164684:5)
Dominant language
JavaScript
Stars
140
Forks
100
Avg merge
1h 3m
Merged PRs (30d)
30

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from openedx/paragon

All issues in openedx/paragon

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.