如何使用非基础本地化在 Xcode 中预览 Storyboard
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22857046/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to preview Storyboard in Xcode using Non-Base localisation
提问by Ben Clayton
I have a Storyboard in Xcode 5.1 with a base Localization of English, and a second Localization in French.
我在 Xcode 5.1 中有一个 Storyboard,基本本地化为英语,第二个本地化为法语。
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)?
当我使用 Xcode Storyboard 编辑器时,字符串按预期以英文显示。有什么方法可以让 Xcode 在我的其他本地化(法语)中显示 Storyboard?
I don't want to change Mac OSX's language, I'm hoping there's an option in Xcode somewhere.
我不想更改 Mac OSX 的语言,我希望 Xcode 中的某个地方有一个选项。
EDIT: I have this in my resources folder
编辑:我的资源文件夹中有这个
If I double-click Main.storyboard then the storyboard opens showing English (base language), as expected.
如果我双击 Main.storyboard,那么故事板会按预期打开,显示英语(基本语言)。
Is there a way to view Main.storyboard, but showing the text displayed in Main.strings?
有没有办法查看 Main.storyboard,但显示 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.
编辑:我已经发现(感谢本教程)在 Xcode 中有一个“预览”选项。要获得此功能,请打开情节提要,单击“助手”编辑器,单击“助手编辑器菜单按钮”(紧靠助手窗口左上角的 > 箭头右侧)并选择“预览”。这显示了 ViewController 在横向/纵向 568/480 高模式下的外观。非常方便,但仍以英文显示所有内容。
If only this'd let me select a localization, it'd be a great way to check the text layout works in different languages..
如果这能让我选择本地化,那将是检查不同语言的文本布局工作的好方法..
采纳答案by Jorge
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:
我相信 Xcode 不准备在使用字符串文件时在 Interface Builder 中显示本地化的故事板。但是,它允许您非常轻松地转换格式。选择您的故事板文件,然后在实用程序面板中,选择您要预览的语言:
Change the "Localizable Strings" to "Interface Build Cocoa Touch Storyboard":
将“Localizable Strings”改为“Interface Build Cocoa Touch Storyboard”:
You should now be able to select the French storyboard file and preview it within IB.
您现在应该能够选择法语故事板文件并在 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.
完成后,您可以通过反转此过程或使用源代码版本控制系统将文件转换回“可本地化字符串”。然后,您可以通过任何必要的调整来更新基本文件,并再次使用此方法验证它是否符合您的喜好。
回答by Ben Clayton
Xcode 6 now includes a feature to do this.
Xcode 6 现在包含一个功能来执行此操作。
From What's New in Xcode - New Features in Xcode 6:
来自Xcode 中的新功能 - 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.
在界面生成器中预览。在 Interface Builder 中进行设计时,预览助手可以显示界面在其他语言中的显示方式。您可以看到您的界面如何响应更长或更短的语言。
Hurrah!
欢呼!
回答by IndiaNasirJones
Just click on you storyboard file and you can devellope it to show your Localization storyboard. In Your case if you use the localization "base" option, you must see 3 storyboard file (one for "base localization", one for english and one for french). Sorry for my english but i hope that help you.
只需单击您的故事板文件,您就可以开发它以显示您的本地化故事板。在您的情况下,如果您使用本地化“基础”选项,则必须看到 3 个故事板文件(一个用于“基础本地化”,一个用于英语,一个用于法语)。对不起我的英语,但我希望能帮助你。