Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to preview Storyboard in Xcode using Non-Base localisation

I have a Storyboard in Xcode 5.1 with a base Localization of English, and a second Localization in French.

When I'm using the Xcode Storyboard editor the strings are shown in English, as expected. Is there any way to make Xcode display the Storyboard in my other localization (French)?

I don't want to change Mac OSX's language, I'm hoping there's an option in Xcode somewhere.

EDIT: I have this in my resources folder one storyboard and one strings folder

If I double-click Main.storyboard then the storyboard opens showing English (base language), as expected.

Is there a way to view Main.storyboard, but showing the text displayed in Main.strings?

EDIT: I've since discovered (thanks to this tutorial) that there's a 'preview' option in Xcode. To get this, open the storyboard, click the 'assistant' editor, click the 'assistant editor menu button' (immediately to the right of the > arrow at the top left of the assistant window) and select Preview. This shows how the ViewController will look in landscape/portrait 568/480 high modes. Very handy, but still shows everything in English.

If only this'd let me select a localization, it'd be a great way to check the text layout works in different languages..

xcode preview feature

like image 597
Ben Clayton Avatar asked Apr 04 '14 08:04

Ben Clayton


People also ask

Why is Main storyboard not showing up in Xcode?

You have SwiftUI enabled in your project, which does not use storyboards anymore. Your layout is inside the ContentView. swift file. If you do want to work the old way, with storyboards, you should uncheck 'Use SwiftUI' in the project creation screen.

How do I use storyboard reference in Xcode?

storyboard and choose Refactor to Storyboard ... from Xcode's Editor menu. Xcode prompts you to name the storyboard which the Note View Controller scene is moved to. Name the storyboard NoteViewController. storyboard and click Save.

Is there any way to use storyboard and SwiftUI in same iOS Xcode project?

Yes you can do that! Here are the steps you can take to do so: Go to your current Xcode project -> Storyboard, click on the + sign (right upper corner) and search for Hosting Controller (just like you would for a button or label). Drag Hosting Controller to your Storyboard.


2 Answers

I believe that Xcode is not prepared to show localized storyboards in Interface Builder when using string files. However, it allows for you to convert formats quite easily. Select your storyboard file and in the utilities panel, select the language you want to preview:

Utilities Panel

Change the "Localizable Strings" to "Interface Build Cocoa Touch Storyboard":

Selection

You should now be able to select the French storyboard file and preview it within IB.

Once you are done, you can convert the file back to "Localizable Strings" reversing this procedure, or using your source code version control system. Then you can update the base file with any necessary adjustments, and verify it is to your liking using this method again.

like image 146
Jorge Avatar answered Sep 21 '22 14:09

Jorge


Xcode 6 now includes a feature to do this.

From What's New in Xcode - New Features in Xcode 6:

Preview in Interface Builder. While designing in Interface Builder, the preview assistant can show how the interface appears in other languages. You can see how your interface responds to longer or shorter languages.

Hurrah!

like image 42
Ben Clayton Avatar answered Sep 18 '22 14:09

Ben Clayton