Tuesday, December 30, 2008

Localizable.strings problem in iPhone apps

Lately I have been writing an iPhone application that needs to work in English and Turkish.
I used NSLocalizedString macro all across my code, then ran 'genstrings' from command-line to generate the Localizable.strings file with the key-value pairs.
In XCode, I selected Localizable.strings, hit the 'Info' button and then hit the 'Make file localizable' button. I then used the 'Add Localization' to add 'tr' support. I updated the Turkish version of the file with translated strings.

It all looked good when I tested on the simulator. Pretty cool. But while testing on the actual device, I noticed that the strings were not being replaced with their Turkish translations.

iPhone documentation says the Localizable.strings file needs to be in UTF-16 encoding. But suprisingly, if you are using SDK 2.2, the file generated when you hit the 'Add Localization' button is in UTF-8 encoding. So just because you added the original Localizable.strings file in XCode by specifying UTF-16 econding, do not assume that XCode will stick to that for its localized copies. To change the file's encoding to UTF-16 from UTF-8, use 'View' --> 'Text' --> 'File Encoding' in XCode menu.

'Clean', 'Build', and it all works!

10 comments:

  1. Thanks, you made my day!

    ReplyDelete
  2. Thank you! You saved us hours!

    ReplyDelete
  3. I never would have figured that out. Thanks!!

    ReplyDelete
  4. Wow. I was about to go nuts over this. Thanks a lot!

    ReplyDelete
  5. Hey very cool site!! Man .. Excellent .. Amazing .. I
    will bookmark your blog and take the feeds also? I'm happy to seek out a lot of useful info here within the publish, we'd
    like develop more techniques in this regard, thanks for sharing.
    . . . . .

    Look into my web site: homemade toys for toddlers

    ReplyDelete
  6. I know this if off topic but I'm looking into starting my own weblog and was wondering what all is required to get setup? I'm assuming having a blog like yours would cost a pretty penny?
    I'm not very internet savvy so I'm not 100% positive. Any tips or advice would be greatly appreciated. Thank you

    My web site heart beat

    ReplyDelete
  7. Hi!
    If you’re interested in a tool to collaboratively localize iOS apps for iPad or iPhone, I suggest you give https://poeditor.com/ a shot. It’s a very user-friendly online translation platform that handles .strings files too, along with other popular language file formats. You’ll see that it has a sum of very useful features to aid your localization workflow, like set reference language and translation memory. Cheers and good luck with your projects!

    ReplyDelete