Skip to content

Fix Cannot access offset of type array on array #341

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

N1ebieski
Copy link
Contributor

@N1ebieski N1ebieski commented Mar 18, 2025

Fixes #340, #272, #262

If someone has an array in a .json translation file, something like this:

{
    "This is a correct translation": "To jest prawidłowe tłumaczenie",
    "This is not a correct translation": {
        "I don't know why people": "Nie wiem dlaczego ludzie",
        "do that": "robią coś takiego"
    }
}

then the extension throws an error:

2025-03-18 12:47:03.650 [error] Translations

Error: __VSCODE_LARAVEL_START_OUTPUT__
   TypeError 

  Cannot access offset of type array on array

  at vendor/_laravel_ide/discover-13e3a4436281ac748c1072dc641041d7.php:302
    298▕     }
    299▕ 
    300▕     protected function getValueIndex($value)
    301▕     {
  ➜ 302▕         $index = $this->values[$value] ?? null;
    303▕ 
    304▕         if ($index !== null) {
    305▕             return $index;
    306▕         }

This PR adds the extra check to verify if the translation is an array.

@mikebrandl
Copy link

I've got exactly the same issue as mentioned above.

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]: [error] Translations Error: __VSCODE_LARAVEL_START_OUTPUT__
2 participants