Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 6 does not localize Interface Builder

Xcode 6 Beta 4 using Swift.

I use localization in my project and I have experience in localization from Xcode 5.

Localization in program code using NSLocalizedString() works fine. Localization of Info.plist strings work fine, too.

When it comes to localize the strings from Interface Builder it only works in Interface Builder preview but not in simulator and not on my device (iPhone 5S).

Am I missing something or can anyone confirm this as a bug in in Xcode 6 Beta 4?

like image 978
zisoft Avatar asked Feb 13 '23 09:02

zisoft


1 Answers

It seems like the problem is with the size classes.

If "Use Size Classes" checkbox is enabled for storyboard, the Xcode actually generates 3 versions of it ("<Name>.storyboard", "<Name>~ipad.storyboard" and "<Name>~iphone.storyboard").

So iOS just tries to load .strings file which name matches the name of active storyboard (<Name>~iphone.strings in case app is running on the iPhone). And being not able to find that file, it falls back to Base localization.

There are a couple of ways to work around this bug:

  1. The most obvious one. Just disable size classes for the storyboard.
  2. If you need size classes, you can add localized <Name>~iphone.strings and <Name>~ipad.strings files to the project manualy and copy your translations over.
like image 75
Dim_ov Avatar answered Feb 16 '23 04:02

Dim_ov