How to add Localization


How can one add localized .strings files to an iOS project with MOE?
I couldn’t find this in the documentation.


Dear Balázs,

In MOE 1.1.x the standard NSLocalizedString*() macros are not mapped to Java. However, you can create your own mapping like this:

public class FoundationExtras {
   public static final String NSLocalizedString(final String key, final String comment) {
    	return NSBundle.mainBundle().localizedStringForKeyValueTable(key, "", null);

You may use this function as follows:

import static FoundationExtras.*;

// ...

NSLocalizedString("I am a localized string", "I am a comment for the string");

In MOE 1.2 we will include the binding for these macros in the apple.Foundation class.

If you created your project with the Keep Xcode option (will be the default from MOE 1.2), then you will need to add your *.lproj bundles to the Xcode project.

If the Xcode project is set to autogenerated, then you can put the *.lproj bundles in src/main/resources and they will be picked up automatically.

Best Regards,

1 Like

GitHub issue: