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

Directive is cached in a development environment #17

Closed Flerex closed 4 years ago

Flerex commented 4 years ago

By default, directives are cached so whenever their logic is changed, artisan view:clear must be called to ensure it is updated. Currently, the implementation of the @languages directive is that it returns an already computed language array.

While I understand that it has been done on purpose so that the translations don't have to be retrieved with every request or to be cached manually, it can become cumbersome if you're developing the app and constantly adding (or even changing) new language keys.

I propose, instead of changing the current implementation, which is optimal for production, to check if the app is not in production and, if so, simply delete the cache as suggested in Laravel's official documentation, with every request.

With that said, I have to thank you for this package. It has become a must in every project of mine where I'm using React components for some parts of the frontend. Very good job! 💙

iamgergo commented 4 years ago

@Flerex Thanks a lot. I'm a bit afraid about clearing the cached views every time since we don't know what is the intention even on the dev environment.

But I really don't see any other way to solve this and I completely understand that calling view:clear manually all the time is quite annoying. Hopefully, it won't cause any problems, but in the worst case, we can revert it.

Thanks!