3

I'm working on an app for Mac OS X. Now I want every word, title or string displaying on the interface to be localized.

For the time being, I've done most of the work, but I'm confused by the MenuBar in MainMenu.xib.

Is there any method for me to translate the MenuBar item's title directory? Or do I have to make IBOutlet for each item and set their title as an NSLocalizedString?

LYTTE_LJ
  • 79
  • 8

2 Answers2

4

You should definitely take a look at the documentation on localization. Importantly, though, Apple has changed some of the steps as Xcode 4 has evolved; so many of the tutorials have some incorrect steps now. I'll restrict my comments to localization of nibs since that was the nature of the question.

Add new localization in Project/Info tab

Add localization

Just click the (+) which will show a popup menu of localization languages. Choose one.

Choose which resources you want to localize

Choose resources

Localize the nib Now, in the Project Navigator, the MainMenu.xib which I chose to localize has a French localization:

Now multiple localizations under xib

Note that all of your IBOutlets and actions are preserved. Now you can simply work on the display text, formatting, size of UI elements etc. to correspond to the selected xib.

Localization of nib

FluffulousChimp
  • 9,157
  • 3
  • 35
  • 42
  • +1 for the answer that points out the brand new XCode features! – Clafou Sep 18 '12 at 13:31
  • @Clafou Thanks very much. I've followed your steps and luckily some of the MenuItem, such as Undo, Redo, and Special Characters are translated while the others are not. So I just make an IBOutlet for every item and set their title with an NSLocalizedString in the end. Thanks anyway! Your advice really helped me ! – LYTTE_LJ Sep 20 '12 at 01:19
2

I might be rather late, but since I needed that myself, I created a Ruby gem, which you can use to automatically translate (almost all "common") items in MainMenu.xib, once you have added the necessary localization.

All you have to do is install the gem:

sudo gem install cocoalocalize

And run it via the terminal:

cocoalocalize your_project_folder your_app_name

*your_project_folder is the one containing your .lproj folders (e.g. es.lproj, fr.lproj).

Translating the different MainMenu.strings file to all available languages will be taken care of by the tool.

Enjoy! :)

Dr.Kameleon
  • 22,532
  • 20
  • 115
  • 223
  • This is exactly what I am looking for. However, I always end up with `Successfully localized project to 0 languages.` I am using storyboards, may that be an issue? I do have all the language folders with an MainMenu.strings file each before I start the tool. – Daniel Dec 31 '16 at 23:32
  • I ended up using the Translator.app from here: http://stackoverflow.com/a/21239554/345258 – Daniel Jan 01 '17 at 02:07