GENL / matice

Use your Laravel translations in JavaScript.
MIT License
98 stars 14 forks source link

Documentation Question: What do you have to look out for when using "Inertia"? #23

Closed pmochine closed 3 years ago

pmochine commented 3 years ago

Currently, I'm developing my first Inertia project. Everything that should work works correctly. But I'm still not sure if I'm missing something.

For example do I need: php artisan matice:generate for Inertia?

Currently, I'm just using @translations in my app.blade.php. When I'm switching the languages, I'm using the normal <a> tag, not the Inertia links.

But I noticed that @translations is creating all languages:

de: {auth: {…}, pagination: {…}, passwords: {…}, routes: {…}, validation: {…}}
en: {auth: {…}, pagination: {…}, passwords: {…}, routes: {…}, validation: {…}}
hu: {auth: {…}, pagination: {…}, passwords: {…}, routes: {…}, validation: {…}} 

In #10 you are saying: "In production, matice lazy loads the translations.".

I just tried to set APP_ENV=production but it's still the same. Maybe you mean the generated js file from php artisan matice:generate?

Thank you! And p.s. this is a really great package! Really well done!

GENL commented 3 years ago

When using with inertia you should load translations using the blade directive @translations. In production, the matice_translations.js file is auto-generated by the @translations directive (if the file does not already exist). Matice handles it for you, you don't have to call matice:generate yourself.

pmochine commented 3 years ago

@GENL thanks btw for the answer!