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

Get cryptic error Cannot read properties of undefined (reading 'message') for a simple problem #375

Open
4 tasks done
Sinc63 opened this issue Jun 4, 2024 · 1 comment
Labels
Status: Review Needed Request for review comments

Comments

@Sinc63
Copy link

Sinc63 commented Jun 4, 2024

Reporting a bug?

I am updating i18n translations for our project. After running 17 translations for French I started getting an error from the i18n plugin, with none of the stack trace leading back to my code line, just the file name.

Cannot read properties of undefined (reading 'message')
5:56:50 PM [vite] Internal server error: Cannot read properties of undefined (reading 'message')
  Plugin: vite-plugin-vue-i18n
  File: /var/src/project/src/i18n/fr.json
      at newOptions.onError (/var/src/project/node_modules/@intlify/bundle-utils/lib/codegen.js:102:48)
      at newOptions.onError (/var/src/project/node_modules/@intlify/bundle-utils/lib/codegen.js:102:36)
      at newOptions.onError (/var/src/project/node_modules/@intlify/bundle-utils/lib/codegen.js:102:36)
      at emitError (/var/src/project/node_modules/@intlify/message-compiler/dist/message-compiler.cjs.js:197:13)
      at readTokenInPlaceholder (/var/src/project/node_modules/@intlify/message-compiler/dist/message-compiler.cjs.js:681:21)
      at readToken (/var/src/project/node_modules/@intlify/message-compiler/dist/message-compiler.cjs.js:776:20)
      at Object.nextToken (/var/src/project/node_modules/@intlify/message-compiler/dist/message-compiler.cjs.js:823:16)
      at parseNamed (/var/src/project/node_modules/@intlify/message-compiler/dist/message-compiler.cjs.js:910:19)
      at parseMessage (/var/src/project/node_modules/@intlify/message-compiler/dist/message-compiler.cjs.js:1048:37)
      at parseResource (/var/src/project/node_modules/@intlify/message-compiler/dist/message-compiler.cjs.js:1096:25)

The simple problem is that other tools got an invalid translation back. I use I18NAlly to fetch translations (I think from Google), and in this one case:
"from-users-usernames": "from users {usernames}",
became
"from-users-usernames": "des utilisateurs {nom d'utilisateurs}",

It would be very helpful, given that I've seen Google translate parameter names in other cases, if intlify would explicitly detect problems that it can't handle in the parameter name (whether that's the space or the apostrophe or both), and report an explicit error, something like invalid parameter name in translation string "from-users-usernames" in /var/src/project/src/i18n/fr.json:1282. Note that I gave both the tag and the line number, but either would likely be sufficient.

Expected behavior

If a parameter name isn't acceptable an explicit warning should be given, specifying at the very least that a specific string or line number has a problem with the parameter name. Specifying the limitations of the parameter names in the error might be help, if not too cumbersome,. A link to docs might be sufficient. (And note that it's not the case that I expect the tool to support a two word parameter name, I just need it to explicitly detect the problem since the translators sometimes do that to us.)

Reproduction

See my sample and insert it in your favourite app to test.

Issue Package

vite-plugin-vue-i18n

System Info

Need to install the following packages:
  [email protected]

"@intlify/vite-plugin-vue-i18n@^3.3.1":
"@intlify/[email protected]",
vue-i18n@^9.2.0-beta.35:

Screenshot

No response

Additional context

No response

Validations

  • Read the Contributing Guidelines.
  • Read the README
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A open a GitHub Discussion.
@Sinc63 Sinc63 added the Status: Review Needed Request for review comments label Jun 4, 2024
@Sinc63
Copy link
Author

Sinc63 commented Jun 4, 2024

I did some additional translations and my Spanish translations mutilated a @lower:message.message-s reference by translating the lower key. This caused a very similar error in the Intlify code, but this time from readTokenInLinked instead of readTokenInPlaceholder. Please apply the same fix in both.

@kazupon kazupon added Status: Need More Info Lacks enough info to make progress and removed Status: Need More Info Lacks enough info to make progress labels Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Review Needed Request for review comments
Projects
None yet
Development

No branches or pull requests

2 participants