-1

In my iOS app I need an option to change language. Can we change it without changing the language in the device settings

Jobin Jose
  • 288
  • 2
  • 13
  • 1
    go through link .This will solve your problem http://createdineden.com/blog/post/language-changer-in-app-language-selection-in-ios/ – Kuldeep Singh Jun 01 '16 at 12:21

3 Answers3

2

You can use following code to set the language

- (void) setLanguage:(NSString*) lang {
NSString *path = [[NSBundle mainBundle] pathForResource:lang ofType:@"lproj"]; 
if (path == nil) {
    myBundle = [NSBundle mainBundle];
} else { 
    myBundle = [NSBundle bundleWithPath:path];
}
if (myBundle == nil) {
    myBundle = [NSBundle mainBundle];
}
}

And after that you can get the localizations with

- (NSString*) localizedStringForKey:(NSString*) key {
   return [myBundle localizedStringForKey:key value:@"" table:nil];
}
Ketan Parmar
  • 27,092
  • 9
  • 50
  • 75
Miro
  • 97
  • 3
0

For example store different static json/plist and etc in your app with different languages strings and when you switch option parse this and set to labels.

iSashok
  • 2,326
  • 13
  • 21
0

i am not sure but try this code once using NSUserDefaults

NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults];
NSMutableArray* languages = [userDefaults objectForKey:@"AppleLanguages"];
[languages insertObject:@"de" atIndex:0]; // ISO639-1
[[NSUserDefaults standardUserDefaults] synchronize];