Showing posts with label Internationalization. Show all posts
Showing posts with label Internationalization. Show all posts

Friday, October 10, 2008

Internationalization with Cocoa

So It looks like 2/5's of my downloads are from outside of the US, and the majority of my initial comments are Internationalization related. So, I looked to internationalize, and it is as easy as it should be! But most of the Documentation is Reference based, not examples. And well, I much prefer to steal and refactor examples than to understand and learn, so I put these forth for future Internationalization people to steal from!

This Document Is the official documentation for Internationalization. Good, dry reading.

These 3 steps are all I needed to do:

1) Convert XIB files:
- Internationalize XIB files. Select the XIB file in XCode, click the info button, and under general press 'Make Localized'
- Extract strings: ibtool -L MainWindow.xib > ./MainWindow.strings
- Translate: See Post below!
- Re-create new XIB File:ibtool -d de.lproj/MainMenu.strings English.lproj/MainMenu.nib -W French.lproj/MainMenu.nib
2) Use NSLocalizedString wherever you have a user-visible string to display
- Modify Code to use NSLocalizedString
- Generate a Localized.strings file auto-matically with: genstrings -o t1 *.m
This tool is very cool, it actually parses your code and looks for where you use NSLocalizedString and it generates your key/value pairs from the code!
- Translate and copy Localized.strings into the .lproj directories
3) Use the Localized interfaces on any API objects you have.
- For me, the only object was the NSNumberConverter. I was using a direct number converter, and I realized that it took care of things for all locales even easier!

formatter = [[NSNumberFormatter alloc] init];
[formatter setNumberStyle:NSNumberFormatterCurrencyStyle];
[formatter setLocale:[NSLocale currentLocale]];




I applaud Apple in their toolchain. It's great that I can develop great user-friendly Apps in a developer-friendly environment!

Anyone else have any Internationalization Tips?