Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode Localization is driving me nuts! Not loading Storyboard

It's been 2 days this issue is driving me nuts.

I'm trying to localize my iOS app but for the life of me I can't get it to work. It works easy enough when I try on a blank project but not on my current project.

I've added the languages in the Localizations using "+", I've localized the storyboard but when I check on simulator or device I still see the english version. And in fact it's not even the English one because if I change the Maintsoryboard (english) I don't see the changes in the device ... I still see the initial texts.

I've tried reseting the simulator, deleted the app, etc. No luck.

I've reverted to a backup tried adding everything again. No luck.

Can someone please help? I know it's not much to go on, but I don't know what to explain to help you help me. So please let me know if I'm missing some info.

FYI, when I look into the app's folder in Developer, I initially don't have a en.lproj when it seems I should have one by default?

like image 903
Stéphane Schorderet Avatar asked Oct 08 '12 13:10

Stéphane Schorderet


3 Answers

It looks like you already figured this out, but I think what probably happened is that originally you had "MainStoryboard.storyboard" as an unlocalized resource. This means that when you build your app, you get a "MainStoryboard.storyboardc" as an unlocalized resource. When you change your storyboard to be localized, you get a "Base.lproj/MainStoryboard.storyboardc" in your bundle resources.

There are several copies of your app when you're building in Xcode. There's the copy on your device or in the simulator, and there's also a copy in your derived data folder in Xcode. When you do an incremental build of your application, the copy in the derived data folder in Xcode is a merge of your new content and your old content. So, when you modify a resource in Xcode, and rebuild, you get the newest resource. However when you rename or delete resources, the old copy is still left in the build directory until you perform a clean operation.

This means that your build product probably had both "MainStoryboard.storyboardc" and "Base.lproj/MainStoryboard.storyboardc". When NSBundle loads resources, it prefers unlocalized content, and would load the old "MainStoryboard.storyboardc".

like image 51
Jon Hess Avatar answered Nov 16 '22 03:11

Jon Hess


Be absolutely sure you don't have typos in Main.strings file, e.g. double quotes and semicolons. If you have any typos, device simply ignores localized strings and applies base internationalization.

like image 25
Farshid Avatar answered Nov 16 '22 02:11

Farshid


Blind shot: check that the strings file is UTF-16 (little endian if I remember correctly) and it doesn't have syntax errors (missing ; or quote). Also run a project clean before building after changes in strings files.

like image 30
djromero Avatar answered Nov 16 '22 04:11

djromero