Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: select preferred language which is supported by the app #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions ios/LocalizationSettings.mm
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,12 @@ -(NSString*) getLanguageTag:(NSString *)language {
return [[locale languageCode] stringByAppendingFormat:@"-%@", [currentLocale countryCode]];
}

-(NSString*) getUserLocale {
NSArray* locales = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"];
if (locales == nil ) { return nil; }
if ([locales count] == 0) { return nil; }

NSString* userLocale = locales[0];
return userLocale;
}

/**
* Get current language
* returns string in IETF BCP 47 (language-COUNTRY "pl-PL")
**/
- (NSString *)getCurrentLanguage {
NSString *userLocale = [self getUserLocale];
if (userLocale) {
return userLocale;

}
return [[NSLocale preferredLanguages] objectAtIndex:0];
return [self getLanguageTag:[[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0]];
}

/**
Expand Down