Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ztioge's avatar

Laravel Lang in Javascript

Hi everyone,

I installed this laravel-js-localization package in my project:

https://github.com/andywer/laravel-js-localization

I followed every steps but I did not manage to make it work.

My js-localization.php file looks like this, if I understand correctly the following code should let me use the alpha_spaces language tag that is in the validation.php file in my javascript file.

    'messages' => [
      'validation.alpha_spaces',
    ],

This is the part where I'm using the package in the blade:

document.write( Lang.get('validation.alpha_spaces') );

But the only thing that it does is write the string 'validation.alpha_spaces' on the blade, it doesn't translate anything.

If you need more explanation let me know.

Thanks in advance.

0 likes
1 reply
ztioge's avatar
ztioge
OP
Best Answer
Level 1

Okay, I restarted the application, and today it works.

Please or to participate in this conversation.