andywer / laravel-js-localization

Simple, ease-to-use and flexible package for the Laravel web framework. Allows you to use localized messages of the Laravel webapp (see `resources/lang` directory) in your Javascript code.
MIT License
143 stars 51 forks source link

Support splitting up messages.js to locale-based .js files #48

Closed carestad closed 6 years ago

carestad commented 6 years ago

Seeing as loading the whole messages.js file might be a bit too much, I have added support for splitting up the whole messages.js into .js files for each locale (lang-en.js, lang-es.js etc.).

This way, one could chose to only load the translations for the user's language, by checking App::getLocale().

Also added a @yield (@yield('js-localization.head.exported')) in the view for this that will check for the exported files and include accordingly.

Also updated docs and did some small indent fixes as well.

andywer commented 6 years ago

The @section('js-localization.head.exported') is quite hard to understand (see my comment), but if we can make that a bit easier to read it's ready for merge.

Thanks for sharing this!