lokalise / i18n-ally

🌍 All in one i18n extension for VS Code
https://marketplace.visualstudio.com/items?itemName=lokalise.i18n-ally
MIT License
3.87k stars 307 forks source link

TypeError: Cannot read properties of undefined (reading 'getValueByKey') #1077

Open janvorwerk opened 7 months ago

janvorwerk commented 7 months ago

Describe the bug

Extension fails to detect/parse my language JSON files.

Found a crash in the logs.

Extension Version

2.12.0 - 2023-09-23

Framework/i18n package you are using

next-intl

To Reproduce

Nothing to do, just try to use it (more below)

Device Infomation

Extension Log Go to View -> Output -> i18n Ally, and paste the content below. You should mask any sensitive information

🈢 Activated, v2.12.0

――――――

πŸ’Ό Workspace root changed to "/Users/jan/code/sportlek"
🌞 Enabled
🧩 Enabled frameworks: next-intl
🧬 Enabled parsers: json, yaml, json5

πŸ“ˆ Telemetry id: *************
πŸš€ Initializing loader "/Users/jan/code/sportlek"
🧰 Config "i18n-ally.enabledFrameworks" changed, reloading
πŸ” Reloading loader
🧩 Enabled frameworks: next-intl, React
🧬 Enabled parsers: json, yaml, json5

πŸš€ Initializing loader "/Users/jan/code/sportlek"
🧰 Config "i18n-ally.enabledFrameworks" changed, reloading
πŸ” Reloading loader
🧩 Enabled frameworks: next-intl, React, General
🧬 Enabled parsers: json, yaml, json5

πŸš€ Initializing loader "/Users/jan/code/sportlek"
🧰 Config "i18n-ally.enabledFrameworks" changed, reloading
πŸ” Reloading loader
🧩 Enabled frameworks: next-intl, React, General, VS Code
🧬 Enabled parsers: json

πŸš€ Initializing loader "/Users/jan/code/sportlek"

Nothing very helpful here... however, digging further, I found this: /Users/jan/Library/Application Support/Code/logs/20240119T104856/window1/exthost/exthost.log

2024-01-19 11:01:52.400 [error] TypeError: Cannot read properties of undefined (reading 'getValueByKey')
    at ComposedLoader.getValueByKey (/Users/jan/.vscode/extensions/lokalise.i18n-ally-2.12.0/dist/extension.js:313068:34)
    at refresh (/Users/jan/.vscode/extensions/lokalise.i18n-ally-2.12.0/dist/extension.js:314345:31)
    at f.<anonymous> (/Users/jan/.vscode/extensions/lokalise.i18n-ally-2.12.0/dist/extension.js:314415:91)
    at invokeFunc (/Users/jan/.vscode/extensions/lokalise.i18n-ally-2.12.0/dist/extension.js:122168:19)
    at leadingEdge (/Users/jan/.vscode/extensions/lokalise.i18n-ally-2.12.0/dist/extension.js:122178:22)
    at f.debounced [as value] (/Users/jan/.vscode/extensions/lokalise.i18n-ally-2.12.0/dist/extension.js:122245:16)
    at n.y (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:80:1902)

The time matches.

Screenshots

image

Config

I am using a monorepo, so the root package.json does not contain many dependencies. Auto-detect failed (it took me a while to figure out already) and I had to specify the enabledFrameworks inspired from your tests

{
  "i18n-ally.sourceLanguage": "fr",
  "i18n-ally.localesPaths": ["./packages/i18n"],
  "i18n-ally.pathMatcher": "{locale}.json",
  "i18n-ally.keystyle": "nested",
  "i18n-ally.enabledFrameworks": [
    "next-intl",
    "react",
    "general",
    "vscode"
  ]
}

The i18n fiels are in a dedicated folder

image

The fr.json file starts with:

{
  "ariaLabels": {
    "appLogo": "Logo de Sportlek",
    "error": "Erreur",
    "mainNav": "Navigation principale",
    "progress": "En cours…",
    "settingsNav": "Navigation dans les paramètres",
    "success": "Succès"
  },
  "calendar": {
mohamedamara1 commented 7 months ago

+1, getting the same issue too