@@ -28,8 +28,6 @@ export default {
28
28
}
29
29
this . _i18n = options . i18n
30
30
this . _i18nWatcher = this . _i18n . watchI18nData ( )
31
- this . _i18n . subscribeDataChanging ( this )
32
- this . _subscribing = true
33
31
} else if ( isPlainObject ( options . i18n ) ) {
34
32
// component local i18n
35
33
if ( this . $root && this . $root . $i18n && this . $root . $i18n instanceof VueI18n ) {
@@ -59,8 +57,6 @@ export default {
59
57
60
58
this . _i18n = new VueI18n ( options . i18n )
61
59
this . _i18nWatcher = this . _i18n . watchI18nData ( )
62
- this . _i18n . subscribeDataChanging ( this )
63
- this . _subscribing = true
64
60
65
61
if ( options . i18n . sync === undefined || ! ! options . i18n . sync ) {
66
62
this . _localeWatcher = this . $i18n . watchLocale ( )
@@ -73,11 +69,33 @@ export default {
73
69
} else if ( this . $root && this . $root . $i18n && this . $root . $i18n instanceof VueI18n ) {
74
70
// root i18n
75
71
this . _i18n = this . $root . $i18n
76
- this . _i18n . subscribeDataChanging ( this )
77
- this . _subscribing = true
78
72
} else if ( options . parent && options . parent . $i18n && options . parent . $i18n instanceof VueI18n ) {
79
73
// parent i18n
80
74
this . _i18n = options . parent . $i18n
75
+ }
76
+ } ,
77
+
78
+ beforeMount ( ) : void {
79
+ const options : any = this . $options
80
+ options . i18n = options . i18n || ( options . __i18n ? { } : null )
81
+
82
+ if ( options . i18n ) {
83
+ if ( options . i18n instanceof VueI18n ) {
84
+ // init locale messages via custom blocks
85
+ this . _i18n . subscribeDataChanging ( this )
86
+ this . _subscribing = true
87
+ } else if ( isPlainObject ( options . i18n ) ) {
88
+ this . _i18n . subscribeDataChanging ( this )
89
+ this . _subscribing = true
90
+ } else {
91
+ if ( process . env . NODE_ENV !== 'production' ) {
92
+ warn ( `Cannot be interpreted 'i18n' option.` )
93
+ }
94
+ }
95
+ } else if ( this . $root && this . $root . $i18n && this . $root . $i18n instanceof VueI18n ) {
96
+ this . _i18n . subscribeDataChanging ( this )
97
+ this . _subscribing = true
98
+ } else if ( options . parent && options . parent . $i18n && options . parent . $i18n instanceof VueI18n ) {
81
99
this . _i18n . subscribeDataChanging ( this )
82
100
this . _subscribing = true
83
101
}
0 commit comments