Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Vue Language Translation

can someone show me a working example of vue-router together with vue-i18n , I am working with laravel and vue, had all my translations ready for laravel, now I converted them to javascript translations using laravel-vue-i18n-generator plugin

however when I go use them on my component.vue files, I get this warning http://prntscr.com/bkg9qo

Any Help would be appreciated.

like image 521
Zem Avatar asked Nov 08 '22 13:11

Zem


1 Answers

It's a pretty old question, but this problem is really common. So for further views this is the answer!

in your app.js file import the 2 below :

import VueInternalization from 'vue-i18n';

import Locales from './vue-i18n-locales.generated.js'; (this will be generated through the artisan command vue-i18n:generate

and before the const declaration as of shown below I imported this forEach

Object.keys(Locales).forEach(function (lang) {
   Vue.locale(lang, Locales[lang])
});

const app = new Vue({
    el: '#app'
});

And finally to set the locale I added the following lines to my app.blade.php

<script type="text/javascript">
    Vue.config.lang = '{{ app()->getLocale() }}';
</script>

Hope this helps!

like image 87
Stefano Groenland Avatar answered Nov 15 '22 10:11

Stefano Groenland