Search code examples
objective-cios9uimenuitem

How to automatically set the language of UIMenuItems?


I am trying to add speech functionality to my app via the UIMenuController, with a custom UIMenuItem. My question is this: If I need to support multiple languages, do I have to define the title of the UIMenuItems in those multiple languages as well? -I have looked everywhere, so this is kinda last resort type stuff :)

-I greatly appreciate any help, and thank you in advance :)


Solution

  • As far as I can see, UIMenuItem title is NSString https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIMenuItem_Class/index.html#//apple_ref/occ/instm/UIMenuItem/initWithTitle:action:

    so you can use Localized string:

    https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/#//apple_ref/occ/clm/NSString/localizedStringWithFormat:

    You will have to create localized string where you can put your strings in different languages:

    http://www.raywenderlich.com/64401/internationalization-tutorial-for-ios-2014