Search code examples
iosxcodetranslate

Translate iPhone App to Chinese


Im making an app for a client who has asked if I can make a Chinese version for him, or add a translate button within the app to make everything Chinese. Is there a way to do this within Xcode, or some way to take the phones language and translate the app?


Solution

  • The best way to do that is making your app Localizable. To do that:

    1. Create a file named Localizable.strings (the name and the type are important);
    2. Select the created file and press the "Make localized..." button on the right pane (File Inspector);
    3. Select English and click "Localize";
    4. Go to your Project Info tab;
    5. There is a new item on this page named "Localizations", click the "+" icon and select Chinese;
    6. Select the items you want to localize. Here I suggest let only the created file Localizable.strings and click Finish;
    7. You will see a indicator in your Localizable.strings that let you expand. Do it;
    8. You will see two files: one for English and another for Chinese. You have to put your text in both with a identifier. Here's an example:

      //English "start" = "Start:"; "end" = "End:"; "new" = "New";

      //Chinese "start" = "TextInChinese:"; "end" = "TextInChinese:"; "new" = "TextInChinese";

    9. In order to access these information in your code, you have to use the following code:

    _variable.text = [NSString stringWithFormat:NSLocalizedString(@"start", @"Some Coment you want to use")];

    That will do the job you want.