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

Static generation getting started #59

Closed jdbaculard closed 6 years ago

jdbaculard commented 6 years ago

I've got a problem with static generation. How I add in the ?

without use @include('js-localization::head') and @yield('js-localization.head')

I use :export command The messages.js's file is updated but it is don't use in live

andywer commented 6 years ago

Just include the JS code and the messages.js via <script> or include it in your JS bundle (if bundling) and you can use the localizations in your JS code.

jdbaculard commented 6 years ago

Thanks. Sorry but it is not working for me

<script src="js/localization.min.js"></script>
<script src="js/messages.js"></script>

TypeError: Cannot read property 'home.add' of undefined"

home.add it is my string

andywer commented 6 years ago

Any 404s? Have you configured the messages you want to export export in the config file (messages key) before exporting? (See readme)

jdbaculard commented 6 years ago

Yes I do But after in vuejs it isn't working

andywer commented 6 years ago

If you are using Vue.js you are probably bundling with webpack or so. Did you put the <script src="js/messages.js"></script> before the <script> of your bundle?

Otherwise it's barely possible to debug that remotely, sorry.

andywer commented 6 years ago

@jdbaculard Have you been able to resolve that issue?

jdbaculard commented 6 years ago

Yes. Thank you very much

andywer commented 6 years ago

Awesome! :)