问题描述
我使用了几个故事板,我刚刚决定将它们本地化(.strings文件已由Xcode生成)。
I use several storyboards and I have just decided to localize them (.strings files have been generated by Xcode).
我注意到在构建阶段>复制捆绑资源,与本地化相关的所有资源都以红色显示。
I notice that in the Build Phases > Copy Bundle Resources, all resources related to localization appear in red.
在运行时,本地化仅适用于主故事板。使用Localizable.strings进行本地化也很有效。但它不在其他故事板上。
At run time, localization works only on the main storyboard. Localization with Localizable.strings also works. But it doesn't on the other storyboards.
我试图重新启动Xcode但它没有改变任何东西。 (参见)
I tried to restart Xcode but it didn't change anything. (cf Base internationalization and multiple storyboard not working right)
我之前编译了本地化的故事板。如果我添加另一个故事板,本地化它并编译,它会因此错误而失败:
My localized storyboards were previously compiled. I f I add another storyboard, localize it and lauch the compilation, it fails with this error:
***由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因: '无法在捆绑NSBundle中找到名为'维护'的故事板(...)
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Could not find a storyboard named 'Maintenance' in bundle NSBundle (...)
您有什么想法解决这个问题吗?
Do you have any idea to solve this issue?
推荐答案
此错误可能是由于未实现您选择在应用程序设置中本地化的其他语言。
为了在故事板中实现语言:
In order to implement a language in a storyboard :
- 选择故事板
- 在右侧面板上,转到文件检查器选项卡(左起第一个)
- 在本地化中,检查所有语言
- Select the storyboard
- On the right panel, go to the File inspector tab (first from the left)
- In Localization, check all language(s)
您现在有两种方法来本地化您的故事板:
You now have two ways to localize your storyboard :
- 您选择为y创建
.strings
文件选择可本地化的字符串,我们的语言会生成一个在故事板中找到的字符串xcode列表。 - 或者您可以选择创建子 - 存储板选择 Interface Builder Cocoa Touch Storyboard ,为特定语言创建不同版本的故事板。
- Either you choose to create a
.strings
file for your language by choosing Localizable Strings, this will generate a list of strings xcode found in your storyboard. - Or you can choose to create a "sub"-storyboard by choosing Interface Builder Cocoa Touch Storyboard which creates a different version of your storyboard for a particular language.
到目前为止,我只找到一种方法来刷新xcode中的.strings文件,如果你添加了新的字符串:只需取消选中并重新检查语言,然后在询问时选择替换文件。 。最后它是自动的。
So far I only found one way to refresh the .strings file in xcode if you add new strings : simply uncheck and recheck the language and select "Replace File" when asked. Apple also provides a tool you can use in the terminal. Finally there's a script that does it automatically.
这篇关于IOs7多故事板本地化问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!