0

Possible Duplicate:
Getting current device language in iOS?

I have an app which uses a tab bar controller with two views. In the first tab, I have taken all of the text fields and localized them. In the second tab, I want to place a translated HTML file for help/instructions on using my app. I have one file for each of the six languages that my app supports.

How can I tell what language the iOS has chosen based on location, so I can load the correct file into the web view?

I have searched Google and SO, and found nothing specific to this question.

Community
  • 1
  • 1
SpokaneDude
  • 4,856
  • 13
  • 64
  • 120

1 Answers1

2

Use

NSString *sysLangCode = [[NSLocale preferredLanguages] objectAtIndex:0];
  • While this is the correct answer to the title, I don't think it's what the OP should use. He seems to have general problems about how to localize an app. – DrummerB Sep 06 '12 at 15:57
  • 1
    DrummerB: I do NOT have a general problem localizing an app... I just needed to know how to tell what the language was, having never had to know before. – SpokaneDude Sep 06 '12 at 15:58
  • @DrummerB this post perfectly answers the "how can I programmatically determine what the localization language is?" question. Furthermore, to the "How can I tell what language the iOS has chosen based on location, so I can load the correct file into the UIWeb view?" one also... –  Sep 06 '12 at 16:00
  • 1
    Well, I still don't understand why you'd want to use NSLocale for this? Why don't you just make the HTML file localizable as you probably did with your .strings file(s) and let iOS handle the rest for you? I've included a localized HTML file in one of my own apps as documentation and it worked fine. – DrummerB Sep 06 '12 at 16:12
  • @DrummerB you may be right, but that's the OP's decision - I just answered his question :) –  Sep 06 '12 at 16:42