How to convert ISO language code to its language name in Objective-C?

I get ISO language codes from the API in my iOS app. For example, en for English, hi for Hindi, etc. I would like to convert these ISO codes to the corresponding language names.

This is returned by the API:

 "category": "TVCHANEL", "chanellanguage": "ar", 

How can i do this? Should I create an ISO code dictionary as a key for each language?

+5
source share
1 answer

You can use NSLocale for this. Below are 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 

Hope this is what you need.

+16
source

All Articles