Code 4 Game

code for our lovely game

Localize `plist` and `NSLocalizedString` in Unreal Engine 4

In recent, I commited a pull request to Unreal Engine 4 in GitHub. This request helps you to localise .plist file and NSLocalizedString of your iOS project in Unreal Engine 4.

Please read this manual, if you can’t visit the UnrealEngine in GitHub.

Glad to see it will be incorporated into the 4.19 release.

Problem

You need to localise your iOS project when you want to deploy with different language. In an iOS project, some strings need to be translated.

How to do

  1. Create some folders in [UEProjectDir]/Build/IOS/Resources/Localization/, and the folder’s names are like this [LanguageCode].lproj.
  2. Create a text file, named InfoPlist.strings, in the folder [LanguageCode].lproj/.
  3. Create a text file, named Localizable.strings, in the folder [LanguageCode].lproj/.

The InfoPlist.strings file will translate all strings in the file - info.plist of your iOS project. And the file - Localizable.strings will translate all strings in all code files of your iOS project.

For example:

Your application’s name is “Lovely Game”. And your object-c code contains below lines:

NSString* allRightText = NSLocalizedString(@"All right", @"All right");
NSString* cancelText = NSLocalizedString(@"Cancel", @"Cancel");

Then:

  • English:

    • In InfoPlist.strings file:
    "CFBundleDisplayName" = "Lovely Game";
    "NSCameraUsageDescription" = "The camera is needed to take a picture";
    
    • In Localizable.strings file:
    /* All right */
    "All right" = "All right";
    /* Cancel */
    "Cancel" = "Cancel";
    
  • Chinese:

    • In InfoPlist.strings file:
    "CFBundleDisplayName" = "可爱的游戏";
    "NSCameraUsageDescription" = "需要摄像头用于拍照";
    
    • In Localizable.strings file:
    /* OK */
    "OK" = "确定";
    /* Cancel */
    "Cancel" = "取消";
    
  • French:

    • In InfoPlist.strings file:
    "CFBundleDisplayName" = "Beau Jeu";
    "NSCameraUsageDescription" = "L'appareil photo est nécessaire pour prendre une photo";
    
    • In Localizable.strings file:
    /* All right */
    "All right" = "D'accord";
    /* Cancel */
    "Cancel" = "Annuler";
    

What I do

When the UE4_Editor archives your project to ipa file, my code will copy all files in [UEProjectDir]/Build/IOS/Resources/Localization/ like [UEProjectDir]/Build/IOS/Resources/Graphics/.


That’s all.