conedevelopment / i18n

Push your Laravel translations to the front-end and use them easily with JavaScript.
https://pineco.de/using-laravels-localization-js/
MIT License
129 stars 21 forks source link

Translations can not be updated in view #9

Closed deiberchacon closed 5 years ago

deiberchacon commented 5 years ago

Hello @iamgergo

Thanks for your work on issue #7, your solution efficiently makes the language switch.

However, I see that when updating a translation file, the change is not reflected in the @translations directive. To do it, I need to run again the view:cache command.

iamgergo commented 5 years ago

Hi @deiberchacon ,

Awesome, I'm happy it works!

Well, yes this is a thing that should be as it is. Behind the scenes, every translation is compressed to a JSON object and the package handles them as strings. From that point, it does not use the translations only. It uses only when it generates the strings.

If we generate them dynamically, we are at the same point where we were before. It's not performance friendly. But, since a user can change the application's language the #7 affected the user. But translations can be changed only by the developer.

So I think this behavior is a good one. Also, translations should not be edited every day (usually. But you can run view:clear and then view:cache when you deploy your application. So with every deploy, you can make sure the application has the fresh translations cached and compiled.

deiberchacon commented 5 years ago

@iamgergo, I think this is fine to maintain performance. You are right, there is no problem in executing the view:cache command since it is not something that is often done.

Thanks for the clarification!