I'm very new to iOS and Objective-C and I've been working on a project for an SMS app in which the app contains a text box for the message and that box has a counter for the characters but the counter depends on the language of the text, so my question is how can I identify/detect what language is the user using?
Asked
Active
Viewed 1,695 times
2
-
Hi and welcome to Stack Overflow. Please make sure to only use the Xcode tag for questions about Xcode the IDE, not iOS the platform. I believe you'll fine the answer in the question I nominated as a duplicate. If not please edit your question and indicate what about those answers didn't answer your question. Best of luck! – Carl Veazey Apr 07 '13 at 07:27
-
Thank you and I didn't find these questions before – user2253960 Apr 07 '13 at 08:39
2 Answers
2
You can get user's prefered language list by using NSLocal
:
NSString * language = [[NSLocale preferredLanguages] objectAtIndex:0];
if ([language isEqualToString:@"en"]) {
NSLog(@"user's prefered first language is English");
}

sunkehappy
- 8,970
- 5
- 44
- 65
-
thank you this helped in a part but I don't know why it always returns english only even when I use the other language. Any idea why? – user2253960 Apr 07 '13 at 08:37
0
NSString * language = [[NSLocale preferredLanguages] objectAtIndex:0];
Have a look at this: Getting current device language in iOS?
-
have a look at this tutorial:http://www.raywenderlich.com/2876/how-to-localize-an-iphone-app-tutorial – lakshmen Apr 07 '13 at 08:45