rmariuzzo / Laravel-JS-Localization

🌐 Convert your Laravel messages and consume them in the front-end!
https://github.com/rmariuzzo/laravel-js-localization
MIT License
596 stars 170 forks source link

Undefined offset error (fresh install) #163

Open nunodonato opened 2 years ago

nunodonato commented 2 years ago

Hi I've just installed this package in a laravel 7 app (php 7.3). All ok, except when I run php artisan lang:js this is what I get:

In LangJsGenerator.php line 215:

  Undefined offset: 3  

The only thing different in this project is that the vendor folder is outside the main project folder. Not sure if could be related Any tips?

nunodonato commented 2 years ago

Further digging into it revealed its a problem with a vendor translation that has a .php file mixed with other .json files. The code that converts the file names to keys is expecting a 4 character extension, and gets confused when it meets the .php file

this is in LangJsGenerator.php $key = substr($pathName, 0, -4);