File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -123,6 +123,27 @@ function getValidLocale(userLocale) {
123123
124124 if ( userLocale == 'DEFAULT' ) {
125125 userLocale = window . navigator . userLanguage || window . navigator . language ;
126+ console . log ( 'Detected locale ' + userLocale ) ;
127+
128+ // The i18next can fallback automatically to the dialect, but needs to be used with hyphen and
129+ // we use underscore because the eventPage.js uses Chrome localization that needs underscore.
130+ // If at some moment we get rid of the Chrome localization we can remove all of this
131+ userLocale = userLocale . replace ( '-' , '_' ) ;
132+ // Locale not found
133+ if ( languagesAvailables . indexOf ( userLocale ) == - 1 ) {
134+ // Is a composite locale?
135+ var underscorePosition = userLocale . indexOf ( '_' ) ;
136+ if ( underscorePosition != - 1 ) {
137+ userLocale = userLocale . substring ( 0 , underscorePosition ) ;
138+ // Locale dialect fallback not found
139+ if ( languagesAvailables . indexOf ( userLocale ) == - 1 ) {
140+ userLocale = 'en' ; // Fallback language
141+ }
142+ } else {
143+ userLocale = 'en' ;
144+ }
145+ }
126146 }
147+
127148 return userLocale ;
128149}
You can’t perform that action at this time.
0 commit comments