Based on the message from the user "object2.0", I have compiled several code samples that you can use in your application to change the language of the user interface on the fly.
The main localization class that does the hard work:
-(NSString *) localized:(NSString *) key { GameInfo *gameInfo = [GameInfo sharedInstance]; // langCode should be set as a global variable somewhere NSString *path = [[NSBundle mainBundle] pathForResource:langCode ofType:@"lproj"]; NSBundle* languageBundle = [NSBundle bundleWithPath:path]; return [languageBundle localizedStringForKey:key value:@"" table:nil]; }
Assuming you have this function in a global class called utils, call this function with the following code (for example, to display the word "Settings".
NSLog( [utils localized:@"Settings"] );
To change the language:
[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:langCode, nil] forKey:@"AppleLanguages"];
Chuck smith
source share