Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to localize an iOS storyboard

I've an iPhone storyboard with some views. For instance, a navigation item title is named News, which should be translated for other languages.

When I add a new localization to my storyboard, it created a duplicate of my current storyboard for the new language. Here I can change the title for the navigation item, but for me it does not seem very useful. What if my storyboard contains 100 views and I need to support 10 languages? If I need to change something in my original storyboard, I have to make the same changes for all languages. That seems very odd. In which situations can this be useful?

What can I do instead? Should I have only the english storyboard and manually translate each element in the ViewController using NSLocalizedString?

like image 292
dhrm Avatar asked Nov 29 '11 14:11

dhrm


People also ask

How do I localize Xib files?

strings files from the xib, which make localization pretty straight forward. Right click on the xib file in Xcode, and choose Get Info . Select the General tab and on the bottom click Make File Localizable . Then you will be able to add localizations by clicking Add Localization on that same tab.

How do I localize in SwiftUI?

LocalizedStringKey is a special type that signals SwiftUI to look up localized strings in your bundle. Use it in custom SwiftUI views to make them ready for localization. Enable the "Use Compiler to Extract Swift Strings" build setting to extract LocalizedStringKeys from code when exporting for localization in Xcode.


1 Answers

In iOS 6 there is a Project setting under the Info tab that says "Use Base Internationalization". If you check the box, it will pull all of the strings out of the Storyboard and into internationalized .strings files.

This way you don't have to have multiple copies of the Storyboard.

enter image description here

like image 104
Collin Avatar answered Sep 18 '22 21:09

Collin