Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
613 views
in Technique[技术] by (71.8m points)

iphone - 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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...