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

The package does not support multi-lang apps #7

Closed iamgergo closed 5 years ago

iamgergo commented 5 years ago

Since the translations are generated via blade directive, they are stored statically in the compiled templates. This is performance friendly, however, it does not track the current application locale.

It means, if the application local has been changed, the generated translations will have the previous locale.

iamgergo commented 5 years ago

Some possible solutions:

iamgergo commented 5 years ago

@deiberchacon Hi!

So, I was working on the 2nd way, that I mentioned in my previous comment. Actually, it works. I will write some tests and refactor a bit, then I commit – maybe in a new branch – and you can test if it works well for you as well.

I'll ping you here soon! Thanks!

iamgergo commented 5 years ago

@deiberchacon I committed and tagged the new release.

Now the package supports multi-locale translations and package translations as well. All the available locales are rendered, but behind the scenes, there is a simple switch-case that determines which is the proper based on the current locale.

This way we can have the performance advantage and also we can change the locale without rerendering the views.

You may update your package to the latest version. Be brave to open a new issue to if you find any bug or weird behavior. I close this issue now.

Thank you!