4
votes

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?

2
have you tried upgrading to beta 5, could be a problem with the simulator.Fred

2 Answers

4
votes

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.
4
votes

Apple release notes of XCode 6 GM covers this :

Localization: A storyboard or XIB will not localize correctly if all of the following three conditions are true: The storyboard or XIB uses size classes. The base localization and the build target are set to Universal. The build targets iOS 7.0.