Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Always get ISO 639-2 (three character) language code in iOS?

I'm working on a project that requires a three letter (ISO 639-2) language code to access a REST service. I was hoping to use the current language setting using [[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode]. Unfortunately, this method prefers to return two letter (ISO 639-1) language codes. Is there a way I can force NSLocale to return the updated codes, or is there another method I can use to convert a two letter language code to a three letter language code?

like image 813
Jose Ibanez Avatar asked Jun 22 '11 22:06

Jose Ibanez


2 Answers

Check my code at Github for a category on NSLocale to get an ISO 639.2 language code. It is as simple as:

[[NSLocale currentLocale] ISO639_2LanguageIdentifier];
like image 104
Almer Lucke Avatar answered Sep 28 '22 05:09

Almer Lucke


No, you cannot do that. You have to convert them manually and this is not very simple.

like image 40
sorin Avatar answered Sep 28 '22 05:09

sorin