File tree Expand file tree Collapse file tree 1 file changed +22
-2
lines changed
src/OnboardingSPA/steps/SiteGen/SiteDetails Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,28 @@ const SiteGenSiteDetails = () => {
53
53
} = useDispatch ( nfdOnboardingStore ) ;
54
54
55
55
const isLargeViewport = useViewportMatch ( 'small' ) ;
56
+ const content = getContents ( ) ;
57
+
58
+ // Function to find English in language list or default to first language
59
+ const getDefaultLocale = ( ) => {
60
+ const englishOption = content . languageList . find ( ( [ language ] ) =>
61
+ language . toLowerCase ( ) . includes ( 'english' ) ) ;
62
+ return englishOption ? englishOption [ 1 ] : ( content . languageList [ 0 ] ? content . languageList [ 0 ] [ 1 ] : '' ) ;
63
+ } ;
64
+
65
+ // Set English as default if no locale is selected
66
+ useEffect ( ( ) => {
67
+ if ( ! selectedLocale && content . languageList && content . languageList . length > 0 ) {
68
+ const defaultLocale = getDefaultLocale ( ) ;
69
+ setSelectedLocale ( defaultLocale ) ;
70
+
71
+ // Update the store with the default locale
72
+ if ( defaultLocale ) {
73
+ currentData . sitegen . siteDetails . locale = defaultLocale ;
74
+ setCurrentOnboardingData ( currentData ) ;
75
+ }
76
+ }
77
+ } , [ content . languageList ] ) ;
56
78
57
79
useEffect ( ( ) => {
58
80
setHideFooterNav ( false ) ;
@@ -141,8 +163,6 @@ const SiteGenSiteDetails = () => {
141
163
}
142
164
} ;
143
165
144
- const content = getContents ( ) ;
145
-
146
166
return (
147
167
< SiteGenStateHandler >
148
168
< CommonLayout isCentered >
You can’t perform that action at this time.
0 commit comments