问题描述
(也有类似的问题。有些问题得到了答案,我已经尝试过但发现没有工作。其他人没有得到答案,我认为因为这些问题并没有像我那样提供足够多的细节。)
(There are similar questions. Some resulted in answers that I've tried and found not to work. Others got no answers, I assume because the querents didn't supply as much detail as I'm about to.)
我开始使用适合我的应用的故事板;它包含的字符串是英文的。我想添加法语本地化。我这样做了:
I started with a storyboard that worked well for my app; the strings it contains are in English. I wanted to add a French localization. I did this:
- 添加了基本本地化,转移了
MainStoryboard.storyboard
从en.lproj
到Base.lproj
。 - 已添加法语本地化,克隆
InfoPlist.strings
(英文)
和MainStoryboard.storyboard
(Base)intofr.lproj
。 - 更改了几个字符串(
中的段标题UISegmentedControl
)在法语MainStoryboard.storyboard
。 - 在模拟器中,将语言设置为法语。 / li>
- 从Xcode中删除应用程序。
- Added a base localization, which transferred
MainStoryboard.storyboard
fromen.lproj
toBase.lproj
. - Added a French localization, which cloned
InfoPlist.strings
(English)andMainStoryboard.storyboard
(Base) intofr.lproj
. - Changed a couple of strings (titles of segments in a
UISegmentedControl
) in the FrenchMainStoryboard.storyboard
. - In the Simulator, set the language to French.
- Ran the app from Xcode.
结果:这有效;我正在运行的应用程序中出现了我已更改的字符串。
Result: This worked; my changed strings showed up in the running application.
但我想要充满乐趣。我想使用 .strings
文件进行法语本地化。 (这不仅仅是一种幻想;法语本地化将转交给非技术翻译人员,他们不能指望他们掌握Interface Builder。)所以:
But I want to be all fancy. I want to do the French localization using a .strings
file. (It's not just a matter of being fancy; the French localization will be turned over to nontechnical translators, who can't be expected to master Interface Builder.) So:
- 在Xcode Project
导航器中选择基础MainStoryboard.storyboard
。 - 在文件中在本地化下,检查员将法语
本地化从Interface Builder Cocoa Touch Storyboard更改为
Localizable Strings。 - 接受Xcode警告法语故事板将被丢弃
而支持.strings
文件,该文件显示在助理编辑器中。 - 进行相同的两次编辑;毫无疑问他们是错误的
字符串,因为他们都被评为
IBUISegmentedControl ... segmentTitles
;并且标签文本没有
出现在.strings
文件中的任何其他位置。 - 删除现有(工作)从模拟器复制应用程序。
- 跑完应用程序。
- Selected the base
MainStoryboard.storyboard
in the Xcode Projectnavigator. - In the File inspector, under Localization, changed the Frenchlocalization from "Interface Builder Cocoa Touch Storyboard" to"Localizable Strings."
- Accepted Xcode's warning that the French storyboard will be discardedin favor of a
.strings
file, which appears in the Assistant editor. - Made the same two edits; there's no question of their being the wrongstrings, because they're all commented as
IBUISegmentedControl...segmentTitles
; and the label text doesn'tappear anywhere else in the.strings
file. - Deleted the existing (working) copy of the app from the simulator.
- Ran the app.
结果:视图使用基本(原始英语)本地化,而不是加载法语字符串。
Result: The view uses the base (originally English) localization, instead of loading the French strings.
这不太令人满意。我试过从模拟器中删除应用程序,甚至删除derived-data文件夹。该错误仍然存在。
This isn't satisfactory. I've tried deleting the app from the simulator, and even deleting the derived-data folder. The bug persists.
正如我所说,我无法将 .storyboard
文件转换为非技术翻译。如何让iOS接受来自 .strings
文件的故事板本地化?
As I said, I can't turn a .storyboard
file over to a nontechnical translator. How can I get iOS to accept the storyboard localizations from a .strings
file?
推荐答案
我的 UISegmentedControl
我遇到了同样的问题。事实证明,iOS 6中存在一个错误:.strings故事板本地化不适用于 UISegmentedControl
文本和 UISearchBar
占位符。
请参阅openradar:
I had the same problem with my UISegmentedControl
s. It turns out that there is a bug in iOS 6: .strings storyboard localization won't work on UISegmentedControl
text and on UISearchBar
placeholders.See this openradar: http://openradar.appspot.com/radar?id=2159402
您是否尝试过本地化其他元素,例如 UILabel
s?这应该有效。
Have you tried localizing other elements such as UILabel
s? That should work.
这篇关于故事板+基本本地化+ .strings文件在运行时不会本地化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!