How to display these items in other language?

I search around the web, but I can't find the answer, maybe this question is too simple.

In the app I developed, how to display those default items, such as back BarButtonItem, ImagePicker buttons, or in the UITextView, the pop-up menu with copy, paste, cut, replace and select all, I can't figure out how to display these items in other language, for example, Chinese, Japanese etc.

Thanks.

Answers


I wrote a tutorial on this where I stepped through how to do this (based on an application I localized in six languages):

Developing localized iPhone applications

http://www.pushplay.net/2009/08/developing-localized-iphone-applications/

I also described some of the language/idiom issues I was dealing with, which might be useful to keep in mind. There is the technical problem of how to implement multiple languages, but there is also the communication problem of having things be nonsensical when directly translated out of context...

EDIT: to respond to your comment, I'd still do it the same way (localizing everything). If not, set it up to localize anyway, but only translate the specific strings you want (and leave the rest as English).

If you really want to do everything yourself, you can do this:

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSArray *languages = [defaults objectForKey:@"AppleLanguages"];
NSString *currentLanguage = [languages objectAtIndex:0];

Then you can compare the currentLanguage variable and display the proper text in an if/then/else if/etc code block. I'd probably recommend having an "else display in english" at the end of the code block, just in case the language returned is different from what you were expecting.

EDIT: I just re-read what you were asking, and realized you meant localizing system functions. That's not something you can control -- when a user goes into their Settings and changes their language, all of those system interfaces (like "Cut/Copy/Paste") will automatically be localized. As long as they set their proper language in their Settings, that should work automatically.


Attribute in *-Info.plist "Localization native development region" is responsible for another thing.

CFBundleDevelopmentRegion (String - iOS, Mac OS X) specifies the native region for the bundle. This key contains a string value that usually corresponds to the native language of the person who wrote the bundle. The language specified by this value is used as the default language if a resource cannot be located for the user’s preferred region or language. (Source)

Solutions:

  1. In my app I have custom localization (not standard mechanism with *.lproj). And to say the system that I can handle localization manually with some languages, I set the CFBundleLocalizations (in Xcode "Localizations"). It's array property where you can specify handled languages. In Xcode could be problems to set Localizations attribute to type 'array', solution here.

    CFBundleLocalizations (Array - iOS, Mac OS X) identifies the localizations handled manually by your application. If your executable is unbundled or does not use the existing bundle localization mechanism, you can include this key to specify the localizations your application does handle. Each entry in this property’s array is a string identifying the language name or ISO language designator of the supported localization. (Source)

  2. UIKit is a framework and has localized resources (such pop-up menu of uitextfield). In Bundle settings(*-Info.plist) you can set CFBundleAllowMixedLocalizations (set to YES) to retrieve those resources.

    CFBundleAllowMixedLocalizations (Boolean - iOS, Mac OS X) specifies whether the bundle supports the retrieval of localized strings from frameworks. This key is used primarily by Foundation tools that link to other system frameworks and want to retrieve localized resources from those frameworks. (Source)


Read up on the internationalization technology:

http://developer.apple.com/internationalization/

In particular, the thing you're talking about is known as "Localization".

I just found this tutorial via google:

http://www.switchonthecode.com/tutorials/a-simple-localization-example-for-the-iphone

N.B. "internationalization" is sometimes written as "I18N" because it is such a long word! (Weird acronym, but it's because the word is an 'I' followed by 18 letters and then an 'N')


Need Your Help

MySQL command to drop all non-primary indexes of a table

php mysql indexing sql-drop

Is there a MySQL command that can drop all the extra indexes except for the first one in a single table thus keeping only the primary index?

Move a video within a div

html css html5 video

I'm creating a website with a videoheader.