Skip to content

Commit

Permalink
Fix language initialization when setting is empty
Browse files Browse the repository at this point in the history
Also use [NSLocale preferredLanguages].
  • Loading branch information
koraktor committed Feb 2, 2015
1 parent 58e0c50 commit ba29aea
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Suitcase/Classes/SCLanguage.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ + (void)initialize {

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *currentLanguage = [defaults objectForKey:@"language"];
if ([currentLanguage isEqualToString:@"auto"]) {
currentLanguage = [defaults objectForKey:@"AppleLanguages"][0];
if (currentLanguage == nil || [currentLanguage isEqualToString:@"auto"]) {
currentLanguage = [NSLocale preferredLanguages][0];
}
[self setLanguage:currentLanguage];
}
Expand All @@ -29,8 +29,8 @@ + (NSLocale *)currentLanguage {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *currentLanguage = [defaults stringForKey:@"language"];

if ([currentLanguage isEqualToString:@"auto"]) {
currentLanguage = [defaults objectForKey:@"AppleLanguages"][0];
if (currentLanguage == nil || [currentLanguage isEqualToString:@"auto"]) {
currentLanguage = [NSLocale preferredLanguages][0];
}

return [NSLocale localeWithLocaleIdentifier:currentLanguage];
Expand Down

0 comments on commit ba29aea

Please sign in to comment.