better matching of default keyboard layout

This commit is contained in:
Jesús A. Álvarez 2016-05-14 15:36:50 +02:00
parent eeda15e20e
commit 32734a3226

View File

@ -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"];