سؤال

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?

هل كانت مفيدة؟

المحلول

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");
}

نصائح أخرى

NSString * language = [[NSLocale preferredLanguages] objectAtIndex:0];

Have a look at this: Getting current device language in iOS?

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top