diff options
author | ritsuka <[email protected]> | 2014-08-16 16:05:26 +0000 |
---|---|---|
committer | ritsuka <[email protected]> | 2014-08-16 16:05:26 +0000 |
commit | 66590157361bb0b7e7cf2a4622feee77fd38fe1c (patch) | |
tree | 4507e5e08cd5ab17789071d1698f80eaf961e7a1 /macosx/HBAudioSettings.m | |
parent | b6084716cf4dbfc50596fa8126eb0fa1c0101dfa (diff) |
MacGui: Fixed the languages selection in the built in presets for languages with a native name.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6300 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx/HBAudioSettings.m')
-rw-r--r-- | macosx/HBAudioSettings.m | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/macosx/HBAudioSettings.m b/macosx/HBAudioSettings.m index 4f0f1003d..e5e65ea62 100644 --- a/macosx/HBAudioSettings.m +++ b/macosx/HBAudioSettings.m @@ -55,6 +55,22 @@ return [fallbacks autorelease]; } +- (NSString *)isoCodeForNativeLang:(NSString *)language +{ + const iso639_lang_t *lang = lang_get_next(NULL); + for (lang = lang_get_next(lang); lang != NULL; lang = lang_get_next(lang)) + { + NSString *nativeLanguage = strlen(lang->native_name) ? @(lang->native_name) : @(lang->eng_name); + + if ([language isEqualToString:nativeLanguage]) + { + return @(lang->iso639_2); + } + } + + return nil; +} + - (void)applySettingsFromPreset:(NSDictionary *)preset { // Track selection behavior @@ -85,13 +101,19 @@ { if ([[NSUserDefaults standardUserDefaults] stringForKey:@"DefaultLanguage"]) { - iso639_lang_t *lang = lang_for_english([[[NSUserDefaults standardUserDefaults] stringForKey:@"DefaultLanguage"] UTF8String]); - [self.trackSelectionLanguages addObject:@(lang->iso639_2)]; + NSString *lang = [self isoCodeForNativeLang:[[NSUserDefaults standardUserDefaults] stringForKey:@"DefaultLanguage"]]; + if (lang) + { + [self.trackSelectionLanguages addObject:lang]; + } } if ([[NSUserDefaults standardUserDefaults] stringForKey:@"AlternateLanguage"]) { - iso639_lang_t *lang = lang_for_english([[[NSUserDefaults standardUserDefaults] stringForKey:@"AlternateLanguage"] UTF8String]); - [self.trackSelectionLanguages addObject:@(lang->iso639_2)]; + NSString *lang = [self isoCodeForNativeLang:[[NSUserDefaults standardUserDefaults] stringForKey:@"AlternateLanguage"]]; + if (lang) + { + [self.trackSelectionLanguages addObject:lang]; + } } } } |