@@ -42,38 +42,51 @@ Then generate the include file with
4242php artisan vue-i18n:generate
4343```
4444
45- Assuming you are using a recent version of vue-i18n, adjust your vue app with something like:
45+ Assuming you are using a recent version of vue-i18n (>=6.x) , adjust your vue app with something like:
4646``` js
4747import Vue from ' vue' ;
48- import VueInternalization from ' vue-i18n' ;
49- import Locales from ' ./vue-i18n-locales.generated.js ' ;
48+ import VueInternationalization from ' vue-i18n' ;
49+ import Locale from ' ./vue-i18n-locales.generated' ;
5050
51- Vue .use (VueInternalization );
51+ Vue .use (VueInternationalization );
5252
53- Vue .config .lang = ' en' ;
53+ const lang = document .documentElement .lang .substr (0 , 2 );
54+ // or however you determine your current app locale
5455
55- Object .keys (Locales).forEach (function (lang ) {
56- Vue .locale (lang, Locales[lang])
56+ const i18n = new VueInternationalization ({
57+ locale: lang,
58+ messages: Locale
5759});
5860
59- ...
61+ const app = new Vue ({
62+ el: ' #app' ,
63+ i18n,
64+ components: {
65+ ...
66+ }
67+ }
6068` ` `
6169
62-
63- For older vue-i18n, the initialization looks something like:
64-
70+ For older vue-i18n (5.x), the initialization looks something like:
6571` ` ` js
6672import Vue from ' vue' ;
6773import VueInternationalization from ' vue-i18n' ;
6874import Locales from ' ./vue-i18n-locales.generated.js' ;
6975
70- Vue .use (VueInternationalization, {
71- lang: ' en' ,
72- locales: Locales
76+ Vue .use (VueInternationalization);
77+
78+ Vue .config .lang = ' en' ;
79+
80+ Object .keys (Locales).forEach (function (lang ) {
81+ Vue .locale (lang, Locales[lang])
7382});
7483
7584...
7685` ` `
86+
87+
88+
89+
7790## Using vuex-i18n
7891
7992### vuex-i18n
0 commit comments