Tuesday, December 21, 2010

Localization Tips

Experimenting with Localization, wondering why doesn't it work like in books? Me, too!

You should have one folder per language, e.g. "en.lproj" for English and "fi.lproj" for Finnish. This folder should contain one language specific file, which contains localized text strings:
"myString1" = "Hello, World!";
...which you use in code:
NSLocalizedString(@"myString1", nil)
Tips:
  • Make sure each line ends with semi-colon (EASY TO FORGET)
  • Make sure file is UTF-16 encoded. When in doubt, convert to UTF-8 and then UTF-16: select the file, click to edit, select Xcode menu item View - Text - File Encoding - Unicode (UTF-16) and save
  • Make sure filename is correct e.g. "Localizable.strings" or "Root.strings" (Settings.bundle)

No comments:

Post a Comment