diff options
Diffstat (limited to 'macosx/HBUtilities.m')
-rw-r--r-- | macosx/HBUtilities.m | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/macosx/HBUtilities.m b/macosx/HBUtilities.m index de3fa6b95..47cb53060 100644 --- a/macosx/HBUtilities.m +++ b/macosx/HBUtilities.m @@ -276,6 +276,22 @@ return [name copy]; } ++ (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; +} + + (NSString *)iso6392CodeFor:(NSString *)aLanguage { iso639_lang_t *lang = lang_for_english(aLanguage.UTF8String); |