File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -23,12 +23,6 @@ export function createWidget(container: Element | string,
23
23
widget . config . globalProperties . $i18n = inject . i18n
24
24
widget . config . globalProperties . settings = settings
25
25
26
- watch ( translator . localeRef , ( locale ) => {
27
- if ( locale ) {
28
- translator . locale = locale
29
- }
30
- } )
31
-
32
26
installComponents ( widget )
33
27
34
28
container = typeof container === 'string' ? document . querySelector ( container ) ! : container
@@ -41,5 +35,16 @@ export function createWidget(container: Element | string,
41
35
widget . provide ( 'templates' , templates )
42
36
widget . mount ( container )
43
37
38
+ watch ( translator . localeRef , ( locale ) => {
39
+ if ( locale !== translator . locale ) {
40
+ translator . locale = locale
41
+ }
42
+ if ( locale ) {
43
+ document . querySelectorAll ( '[data-t]' ) . forEach ( ( el ) => {
44
+ el . textContent = translator . t ( ( el as HTMLElement ) . dataset . t )
45
+ } ) ;
46
+ }
47
+ } , { immediate : true , flush : 'post' } )
48
+
44
49
return widget ;
45
50
}
You can’t perform that action at this time.
0 commit comments