I'm getting ISO language codes from an API in my iOS app. For example, en
for English, hi
for Hindi, etc. I'd like to convert these ISO codes to their respective language names.
This is returned by the API:
"category": "TVCHANEL",
"chanellanguage": "ar",
How can I do this? Do I have to create a dictionary with an ISO code as key for every language?
You can use NSLocale
for this. Please refer below examples
NSLocale *locale = [NSLocale localeWithLocaleIdentifier:@"ar"];
NSLog(@"%@", [locale displayNameForKey:NSLocaleIdentifier value:@"ar"]);
Output: العربية
NSLocale *locale = [NSLocale localeWithLocaleIdentifier:@"en"];
NSLog(@"%@", [locale displayNameForKey:NSLocaleIdentifier value:@"ar"]);
Output: Arabic
I hope this is what you require.