Varun Mehta
Varun Mehta

Reputation: 1753

How to implement language Translation in iPhone app?

I need to implement language translation in my app. Could anybody tell how to do that. Actually i am not able to find APIs for it and google translation API v2 is paid.

Upvotes: 1

Views: 1092

Answers (1)

James Webster
James Webster

Reputation: 32066

To localize strings in your code:

-Create a new Localization.strings file

File -> New File -> iOS -> Resources -> Strings file

-Select this file and Show the file inspector

Command + Option + 1

-Click the add button under localization and add a default language (I expect English) and the other languages you want.

-You'll notice that you have a little arrow next to your Localizable.strings file, if you click it, you can see the languages that you've added.

-For each phrase you want to translate, use the following syntax:

"key" = "value"; 

"hello" = "bonjour";

-In your code where you want to use the translation, use NSLocalizedString(@"hello", @"hello"); (The second parameter is a comment, it doesn't matter what value you use here)

When it comes to nibs, you'll need to manually change the strings and re-arrange the text fields etc in each nib.

Upvotes: 4

Related Questions