File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,6 +19,14 @@ globalThis['__NUXT_COLOR_MODE__'] ??= {
1919// @ts -expect-error - dynamic global name
2020globalThis . defineOgImageComponent = fn ( )
2121
22+ // Subscribe to locale changes from storybook-i18n addon (once, outside decorator)
23+ let currentI18nInstance : any = null
24+ addons . getChannel ( ) . on ( 'LOCALE_CHANGED' , ( newLocale : string ) => {
25+ if ( currentI18nInstance ) {
26+ currentI18nInstance . setLocale ( newLocale )
27+ }
28+ } )
29+
2230const preview : Preview = {
2331 parameters : {
2432 controls : {
@@ -81,21 +89,11 @@ const preview: Preview = {
8189 document . documentElement . style . removeProperty ( '--accent-color' )
8290 }
8391
84- // Store reference to i18n instance for locale changes
85- let i18nInstance : any = null
86-
87- // Subscribe to locale changes from storybook-i18n addon
88- addons . getChannel ( ) . on ( 'LOCALE_CHANGED' , ( newLocale : string ) => {
89- if ( i18nInstance ) {
90- i18nInstance . setLocale ( newLocale )
91- }
92- } )
93-
9492 return {
9593 template : '<story />' ,
9694 created ( ) {
9795 // Store i18n instance for LOCALE_CHANGED events
98- i18nInstance = this . $i18n
96+ currentI18nInstance = this . $i18n
9997
10098 // Set initial locale when component is created
10199 if ( locale && this . $i18n ) {
You can’t perform that action at this time.
0 commit comments