In my iPhone app, I can successfully change language inside the app's Settings (just the user have to restart the app). I use the trick mentioned in this post: link . I made some modification. I store the selected language in NSUserDefaults, and in main.m:
int main(int argc, char *argv[]) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
if ( [[NSUserDefaults standardUserDefaults] objectForKey:@"language"] == nil ) {
[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObject:@"hu"] forKey:@"AppleLanguages"];
} else {
[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObject:[[NSUserDefaults standardUserDefaults] objectForKey:@"language"]] forKey:@"AppleLanguages"];
}
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
}
The "default" Info.plist file is in english, I placed it in the root of the project. I made a hungarian translation of this, because of app name. This file is InfoPlist.strings, and I placed it in hu.lproj folder. In this file:
CFBundleDisplayName = "Sör";
If I change the language, after restart the app, everything is work fine (nib files, strings), except of app name. It doesn't change...
Can someone tell me what is the problem?
You have done almost everything you need to do.
You also need to instruct your app that it has a localized app name. You do this by adding the following key to your app's info.plist
LSHasLocalizedDisplayName
set it's type as boolean and it's value to true.
Once you have done this, your app should localize it's name.
You can read more here
EDIT:
One more thing you need to do is create an InfoPlist.strings file in the en.lproj folder and add the same key to it with the English equivalent
CFBundleDisplayName = "<Replace Me>";
Credit for this addition goes to this link
Well the app name is read by iOS which is not set to the language that your app is set to. So it will display the name of the app which is set for the system language.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.