From 32734a32262eb6417d6f54303afb0873e4ebae03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesu=CC=81s=20A=2E=20A=CC=81lvarez?= Date: Sat, 14 May 2016 15:36:50 +0200 Subject: [PATCH] better matching of default keyboard layout --- Mini vMac/AppDelegate.m | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Mini vMac/AppDelegate.m b/Mini vMac/AppDelegate.m index 658cd4d..70184a8 100644 --- a/Mini vMac/AppDelegate.m +++ b/Mini vMac/AppDelegate.m @@ -50,17 +50,15 @@ NSString * const MNVMDidEjectDiskNotification = @"MNVMDidEjectDisk"; - (void)initDefaults { // default settings - NSString *defaultKeyboardLayout = @"US.nfkeyboardlayout"; - NSLocale *locale = [NSLocale currentLocale]; - if ([[locale objectForKey:NSLocaleCountryCode] isEqualToString:@"GB"]) { - defaultKeyboardLayout = @"British.nfkeyboardlayout"; - } else if ([[locale objectForKey:NSLocaleLanguageCode] isEqualToString:@"es"]) { - defaultKeyboardLayout = @"Spanish.nfkeyboardlayout"; - } + NSDictionary *layoutForLanguage = @{@"en": @"British.nfkeyboardlayout", + @"es": @"Spanish.nfkeyboardlayout", + @"en-US": @"US.nfkeyboardlayout"}; + NSString *firstLanguage = [NSBundle preferredLocalizationsFromArray:layoutForLanguage.allKeys].firstObject; NSDictionary *defaultValues = @{@"trackpad": @([UIDevice currentDevice].userInterfaceIdiom != UIUserInterfaceIdiomPad), @"frameskip": @(0), - @"keyboardLayout": defaultKeyboardLayout + @"keyboardLayout": layoutForLanguage[firstLanguage] }; + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults registerDefaults:defaultValues]; [defaults setValue:@(WantInitSpeedValue) forKey:@"speedValue"];