File tree 2 files changed +12
-3
lines changed
2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,10 @@ export function androidLaunchEventLocalizationHandler() {
41
41
}
42
42
43
43
export function overrideLocale ( locale : string ) : boolean {
44
- ApplicationSettings . setString ( '__app__language__' , locale . substring ( 0 , 2 ) ) ;
44
+ let language_code = locale . substring ( 0 , 2 ) ;
45
+ if ( locale . indexOf ( '-' ) < 0 && locale . length == 3 ) {
46
+ language_code = locale ;
47
+ }
48
+ ApplicationSettings . setString ( '__app__language__' , language_code ) ;
45
49
return true ;
46
50
}
Original file line number Diff line number Diff line change @@ -30,7 +30,12 @@ export function androidLaunchEventLocalizationHandler() {
30
30
}
31
31
32
32
export function overrideLocale ( locale : string ) : boolean {
33
- const path = NSBundle . mainBundle . pathForResourceOfType ( locale . substring ( 0 , 2 ) , 'lproj' ) ;
33
+ let language_code = locale . substring ( 0 , 2 ) ;
34
+ if ( locale . indexOf ( '-' ) < 0 && locale . length == 3 ) {
35
+ language_code = locale ;
36
+ }
37
+
38
+ const path = NSBundle . mainBundle . pathForResourceOfType ( language_code , 'lproj' ) ;
34
39
35
40
if ( ! path ) {
36
41
return false ;
@@ -39,7 +44,7 @@ export function overrideLocale(locale: string): boolean {
39
44
bundle = NSBundle . bundleWithPath ( path ) ;
40
45
NSUserDefaults . standardUserDefaults . setObjectForKey ( [ locale ] , 'AppleLanguages' ) ;
41
46
NSUserDefaults . standardUserDefaults . synchronize ( ) ;
42
- ApplicationSettings . setString ( '__app__language__' , locale . substring ( 0 , 2 ) ) ;
47
+ ApplicationSettings . setString ( '__app__language__' , language_code ) ;
43
48
44
49
return true ;
45
50
}
You can’t perform that action at this time.
0 commit comments