File tree Expand file tree Collapse file tree 1 file changed +30
-14
lines changed Expand file tree Collapse file tree 1 file changed +30
-14
lines changed Original file line number Diff line number Diff line change @@ -35,22 +35,38 @@ if (!Object.hasOwnProperty.call(Vue.prototype, 'currentLocale')) {
35
35
} ,
36
36
37
37
set ( locale ) {
38
- if ( locale === 'en' ) {
39
- currentLocale = locale
40
- fluent . bundles = [ enBundle ]
41
- }
42
-
43
- if ( locale === 'uk' ) {
44
- currentLocale = locale
45
- fluent . bundles = [ ukBundle ]
46
- }
47
-
48
- // Not sure why this is needed with nuxt 2
49
- for ( const component of components . keys ( ) ) {
50
- component . $forceUpdate ( )
51
- }
38
+ setLocale ( locale )
52
39
}
53
40
} )
54
41
}
55
42
43
+ function setLocale ( locale ) {
44
+ if ( locale === 'en' ) {
45
+ currentLocale = locale
46
+ fluent . bundles = [ enBundle ]
47
+ }
48
+
49
+ if ( locale === 'uk' ) {
50
+ currentLocale = locale
51
+ fluent . bundles = [ ukBundle ]
52
+ }
53
+
54
+ // Not sure why this is needed with nuxt 2
55
+ for ( const component of components . keys ( ) ) {
56
+ component . $forceUpdate ( )
57
+ }
58
+ }
59
+
56
60
export const supportedLocales = [ 'en' , 'uk' ]
61
+
62
+ if ( module . hot ) {
63
+ module . hot . accept ( '~/locales/en.ftl' , function ( ) {
64
+ enBundle . addResource ( new FluentResource ( enMessages ) , { allowOverrides : true } )
65
+ setLocale ( currentLocale )
66
+ } ) ;
67
+
68
+ module . hot . accept ( '~/locales/uk.ftl' , function ( ) {
69
+ ukBundle . addResource ( new FluentResource ( ukMessages ) , { allowOverrides : true } )
70
+ setLocale ( currentLocale )
71
+ } ) ;
72
+ }
You can’t perform that action at this time.
0 commit comments