Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change locale programmatically

Tags:

iphone

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

like image 671
Shishir.bobby Avatar asked Jun 11 '10 12:06

Shishir.bobby


1 Answers

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);
like image 81
Biranchi Avatar answered Sep 29 '22 07:09

Biranchi