From ba29aeaf833928d5ce2420ec3d6021086e7a1d16 Mon Sep 17 00:00:00 2001 From: Sebastian Staudt Date: Mon, 2 Feb 2015 08:05:20 +0100 Subject: [PATCH] Fix language initialization when setting is empty Also use [NSLocale preferredLanguages]. --- Suitcase/Classes/SCLanguage.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Suitcase/Classes/SCLanguage.m b/Suitcase/Classes/SCLanguage.m index b9c79cb..1575d4e 100644 --- a/Suitcase/Classes/SCLanguage.m +++ b/Suitcase/Classes/SCLanguage.m @@ -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]; } @@ -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];