John Smith
John Smith

Reputation: 11

How to localize iOS (iPhone/iPad) app using only single storyboard?

I was wondering if somebody could explain in the details how I can localize an iOS app using only 1 storyboard. I know how to localize by creating several storyboards(one storyboard for each used language), however I'd like to find out another solution. Thanks.

Upvotes: 1

Views: 623

Answers (2)

Kevin R
Kevin R

Reputation: 8631

The tutorial on raywenderlich.com uses two forms of localization together. The reason is he also checks the storyboard when turning on localisation in image 3: image from ray's tutorial.

So then what?

NSLocalizedString is very useful, any text set programatically can (and should) be localised using this method. Ray's tutorial is still very useful. However, it's not very desirable to create a clone of the storyboard(s) to do translation, it's just not very maintainable in the long run.

And what about storyboards?

The magic happens using the Base Localization feature. Base localization uses the generated objectId's to 'map' different languages to the storyboard.

Do note that this feature is only available using SDK 6.0 and above. Running the app on a lower iOS version will not cause any errors, it'll simply won't work.

  • Go to your project, and select Base Localization, then add any other language. localization

  • Open your storyboard file and check the new language as well. Note the icon is not a storyboard icon, but a simple text file icon. That's a good thing; it won't copy the whole storyboard this time :). enter image description here

  • Note how there is now another file 'under' the storyboard. Xcode automatically generates a file for every language you select.

Upvotes: 2

Midhun MP
Midhun MP

Reputation: 107231

You can se Localization feature for this. You need to add the Localizable.strings file for each supported language and use it for locaization.

You need to use : NSLocalizedString() for fetcing data corresponding to each key.

Check this tutorial for details.

Upvotes: 0

Related Questions