Shishir.bobby
Shishir.bobby

Reputation: 10984

change locale programmatically

HI all,

i hv a table view showing 4 languages english,spanish,german and french,

i created xib's for each view, also created Localizable.strings. everything is working fine when i change language from simulator. whole app gets changed according to language selected..

what i m trying to do is,instead of changing language from simulator's directory of language, i want to change language through my table view,which shows languages. if i tap on table with spanish values, whole app should changes its language.

can we do this.

like simulator's language setting changes language of whole simulator, i want to change language of my app through my app.

hope for a quick reply

help is always appreciated

regards shishir

Upvotes: 6

Views: 5724

Answers (1)

Biranchi
Biranchi

Reputation: 16327

Try the following thing.

NSArray *languages = nil;

languages = [NSArray arrayWithObject:@"en"];
[[NSUserDefaults standardUserDefaults] setObject:languages forKey:@"AppleLanguages"];
[[NSUserDefaults standardUserDefaults] synchronize];

NSString *localizedStr = NSLocalizedString(@"ABOOK", @"Hello");
NSLog(@"String 11 = %@", localizedStr);

Upvotes: 11

Related Questions