@@ -42,38 +42,51 @@ Then generate the include file with
42
42
php artisan vue-i18n:generate
43
43
```
44
44
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:
46
46
``` js
47
47
import 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' ;
50
50
51
- Vue .use (VueInternalization );
51
+ Vue .use (VueInternationalization );
52
52
53
- Vue .config .lang = ' en' ;
53
+ const lang = document .documentElement .lang .substr (0 , 2 );
54
+ // or however you determine your current app locale
54
55
55
- Object .keys (Locales).forEach (function (lang ) {
56
- Vue .locale (lang, Locales[lang])
56
+ const i18n = new VueInternationalization ({
57
+ locale: lang,
58
+ messages: Locale
57
59
});
58
60
59
- ...
61
+ const app = new Vue ({
62
+ el: ' #app' ,
63
+ i18n,
64
+ components: {
65
+ ...
66
+ }
67
+ }
60
68
` ` `
61
69
62
-
63
- For older vue-i18n, the initialization looks something like:
64
-
70
+ For older vue-i18n (5.x), the initialization looks something like:
65
71
` ` ` js
66
72
import Vue from ' vue' ;
67
73
import VueInternationalization from ' vue-i18n' ;
68
74
import Locales from ' ./vue-i18n-locales.generated.js' ;
69
75
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])
73
82
});
74
83
75
84
...
76
85
` ` `
86
+
87
+
88
+
89
+
77
90
## Using vuex-i18n
78
91
79
92
### vuex-i18n
0 commit comments