Creating a localized MonoMac application (both strings and XIB)

After I found exactly zero examples for the great MonoMac library (create OS X Mac applications in C# without the need to install Mono separately on a Mac) on how to do localization of Xcode Interface Builder XIB files, I found one discussion about that topic. With some help of the original poster Florian, I was able to bring up a solution that worked for me.

I’ve assembled an example project that you may download as a ZIP file.

While I found plenty of examples/postings on how to do localization of pure strings (through the „Localizable.strings“ files), I found none on how to do it with whole XIB files.

Basically the folder structure looks like this:

The example contains a localization for German („DE“) and a localization for Englisch (the default, „EN“). Whereas MonoMac places the XIB files (like „MainMenu.xib“ and „MainWindow.xib“) inside the root of the application, I did not manage to make the application multilingual when keeping the structure this way.

Instead, I moved all XIB files that need to be localized/translated into the „en.lproj“ folder. I also placed the strings file „Localizable.strings“ into this folder. Since I need the files for German, too, I copied them to the „de.lproj“ folder, too. Next, I double clicked the XIB files in the German folder, which launched them inside Interface Builder. I then translated them graphically inside Interface Builder, saved, switched back to Mono and was done.

After compiling the application and starting, it showed my correctly a German UI (since my Mac has the German language active) for the main menu, the elements on the main window and also the label was correctly set to the text read from the German „Localizable.strings“ file.

Things to keep in mind:

  • The „Localizable.strings“ files have to be set to the Build Type „Content“.
  • All XIB files (i.e. the English and non-English files) have to be set to the Build Type „InterfaceDefinition“.
  • I first got success after I did a „Clean“ command (right-click on the root node in the Solution Explorer tree) and then a Rebuild command. My guess is that the automatically-generated Xcode project may have interfered somewhat. Also I quit Xcode completely before doing the cleanup.
  • I am unaware if the steps I did are usually and best-practice, since it involves in copying/duplicating whole XIB files which seems to be very error-prone to me.

I’m really happy for any feedback you have for me!

Entwickler-Ressourcen für OS X

Zurzeit arbeite ich mich in die Programmierung unter OS X ein, also native Mac-Anwendungen (nix iPhone, das kann ich ja schon), die in Objective C mit Xcode programmiert werden.

Als Spickzettel für mich selbst deshalb hier nachfolgend ein paar Ressourcen, die nützlich sind.

Allgemeine Notizen

  • Objective-C kompakt„. Gutes Umsteiger-Buch, wenn Ihr schon viel Ahnung von C++, Java oder C# habt und die Sprache Objective C lernen wollt/müsst.
  • IMG2ICNS. Programm-Symbole (Icons) müssen unter OS X im „.icns“-Format sein. Mit diesem Tool könnt Ihr (z.B.) PNG-Bilder nach ICNS wandeln.


Es scheint, dass MonoMac eine mögliche Alternative zu nativem Objective C ist, hier ein paar Links:

Um den Xcode-PackageMaker zu installieren, wie folgt vorgehen:

If you wish to create Installer packages with port pkg, you will also need to install PackageMaker, which is in the „Auxiliary Tools for Xcode“ package as of Xcode 4.3. The download page for this package can be opened via the Xcode -> Open Developer Tool -> More Developer Tools… menu item. After downloading and mounting the disk image, drag the PackageMaker application to your /Applications directory.

Mehr folgt später an dieser Stelle. Als erstes „richtiges“ Programm gibt’s übrigens einen Mini-Client als natives OS-X-Programm für unser tolles Tool Zeta Uploader.