Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
634 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 Reply

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...