故事板 + 基本本地化 + .strings 文件在运行时不本地化 [英] Storyboard + base localization + .strings file does not localize at runtime

查看:25
本文介绍了故事板 + 基本本地化 + .strings 文件在运行时不本地化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(有类似的问题.有些导致我尝试过但发现不起作用的答案.其他人没有答案,我想是因为提问者没有提供我即将提供的详细信息.)

(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.storyboarden.lprojBase.lproj.
  • 添加了法语本地化,它克隆了 InfoPlist.strings(英文)和 MainStoryboard.storyboard (Base) 到 fr.lproj.
  • 更改了几个字符串(aUISegmentedControl) 在法语 MainStoryboard.storyboard 中.
  • 在模拟器中,将语言设置为法语.
  • 从 Xcode 运行应用程序.
  • Added a base localization, which transferred MainStoryboard.storyboard from en.lproj to Base.lproj.
  • Added a French localization, which cloned InfoPlist.strings (English) and MainStoryboard.storyboard (Base) into fr.lproj.
  • Changed a couple of strings (titles of segments in a UISegmentedControl) in the French MainStoryboard.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 项目中选择了基础 MainStoryboard.storyboard导航器.
  • 在文件检查器的本地化下,更改了法语从Interface Builder Cocoa Touch Storyboard"本地化到可本地化的字符串."
  • 接受 Xcode 的法语故事板将被丢弃的警告支持出现在助手编辑器中的 .strings 文件.
  • 进行了相同的两次修改;毫无疑问他们是错的字符串,因为它们都被注释为IBUISegmentedControl...segmentTitles;并且标签文本没有出现在 .strings 文件中的任何其他位置.
  • 从模拟器中删除了应用的现有(工作)副本.
  • 运行应用程序.
  • Selected the base MainStoryboard.storyboard in the Xcode Project navigator.
  • In the File inspector, under Localization, changed the French localization from "Interface Builder Cocoa Touch Storyboard" to "Localizable Strings."
  • Accepted Xcode's warning that the French storyboard will be discarded in favor of a .strings file, which appears in the Assistant editor.
  • Made the same two edits; there's no question of their being the wrong strings, because they're all commented as IBUISegmentedControl...segmentTitles; and the label text doesn't appear 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.

这并不令人满意.我试过从模拟器中删除应用程序,甚至删除派生数据文件夹.错误仍然存​​在.

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 占位符.看到这个开放雷达:http://openradar.appspot.com/radar?id=2159402

I had the same problem with my UISegmentedControls. 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

您是否尝试过本地化其他元素,例如 UILabels?应该可以的.

Have you tried localizing other elements such as UILabels? That should work.

这篇关于故事板 + 基本本地化 + .strings 文件在运行时不本地化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆