diff options
-rw-r--r-- | libhb/lang.c | 19 | ||||
-rw-r--r-- | libhb/lang.h | 5 |
2 files changed, 23 insertions, 1 deletions
diff --git a/libhb/lang.c b/libhb/lang.c index a336268a7..f40520a23 100644 --- a/libhb/lang.c +++ b/libhb/lang.c @@ -202,6 +202,25 @@ static const iso639_lang_t languages[] = static const int lang_count = sizeof(languages) / sizeof(languages[0]); +iso639_lang_t * lang_lookup( const char * str ) +{ + iso639_lang_t * lang; + + for (lang = (iso639_lang_t*) languages; lang->eng_name; lang++) + { + if ((lang->iso639_1 != NULL && !strcasecmp(lang->iso639_1, str)) || + (lang->iso639_2 != NULL && !strcasecmp(lang->iso639_2, str)) || + (lang->iso639_2b != NULL && !strcasecmp(lang->iso639_2b, str)) || + (lang->eng_name != NULL && !strcasecmp(lang->eng_name, str)) || + (lang->native_name != NULL && !strcasecmp(lang->native_name, str))) + { + return lang; + } + } + + return NULL; +} + iso639_lang_t * lang_for_code( int code ) { char code_string[2]; diff --git a/libhb/lang.h b/libhb/lang.h index 0b353573f..21aab70af 100644 --- a/libhb/lang.h +++ b/libhb/lang.h @@ -14,7 +14,7 @@ typedef struct iso639_lang_t { char * eng_name; /* Description in English */ char * native_name; /* Description in native language */ - char * iso639_1; /* ISO-639-1 (2 characters) code */ + char * iso639_1; /* ISO-639-1 (2 characters) code */ char * iso639_2; /* ISO-639-2/t (3 character) code */ char * iso639_2b; /* ISO-639-2/b code (if different from above) */ @@ -23,6 +23,9 @@ typedef struct iso639_lang_t #ifdef __cplusplus extern "C" { #endif +/* find language, match any of names in lang struct */ +iso639_lang_t * lang_lookup( const char * str ); + /* find language associated with ISO-639-1 language code */ iso639_lang_t * lang_for_code( int code ); |