开发者

How to create localized iPhone App?

开发者 https://www.devze.com 2023-03-03 05:28 出处:网络
I have seen 开发者_开发问答many apps which have their interface in many languages like German, French, Dutch,etc.

I have seen 开发者_开发问答many apps which have their interface in many languages like German, French, Dutch,etc.

I would like to know the steps for creating localized version of the iPhone app.

Thanks!


If you are using xcode 4, just add a strings file and call it Localizable.strings

Then click on that file, and in the right explorer window you see "Localizations". Press the '+' sign there. (the file gets deselected, just select it again). Then you see English is added to the list, after that you can add other languages trough the '+' button.

Then, under the Localizable.strings you see other files (one for each language). In those files, you can write something like:

"KEY" = "LOCALIZED VALUE"; "KEY2" = "LOCALIZED VALUE 2"; etc...

In your code, just write: NSLocalizedString(@"KEY", @"") (The second string can be empty, it's just for comments...

That will do it for you... Just remember, the key values need to be the same in all language files, but the value of the key is the localized value for the specific language ;-)

Hope this helps..


Creating the Localizable.strings file directly in Xcode didn't work for me. I had to end up using the command line utility genstrings, such as:

genstrings -o en.lproj *.m genstrings -o es.lproj *.m (for spanish)

This command goes through all the classes with extension *.m and finds the strings that need to be localized (strings using the translation macros, ie NSLocalizedString). It then creates a Localizable.strings file for that language that can be edited.

0

精彩评论

暂无评论...
验证码 换一张
取 消