基本本地化+故事板+ .strings - >没有本地化

时间:2021-08-21 12:42:28

Xcode 4.6, target iOS 6, SDK iOS 6.1

Xcode 4.6,目标iOS 6,SDK iOS 6.1

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:

我开始使用一个适用于我的应用程序的故事板;它包含的字符串是英文的。我想添加法语本地化。我这样做了:

  • Added a base localization, which transferred MainStoryboard.storyboard from en.lproj to Base.lproj.
  • 添加了一个基本本地化,它将MainStoryboard.storyboard从en.lproj转移到Base.lproj。

  • Added a French localization, which cloned InfoPlist.strings (English) and MainStoryboard.storyboard (Base) into fr.lproj.
  • 添加了法语本地化,将InfoPlist.strings(英语)和MainStoryboard.storyboard(Base)克隆到fr.lproj中。

  • Changed a couple of strings (titles of segments in a UISegmentedControl) in the French MainStoryboard.storyboard.
  • 在法语MainStoryboard.storyboard中更改了几个字符串(UISegmentedControl中段的标题)。

  • In the Simulator, set the language to French.
  • 在模拟器中,将语言设置为法语。

  • Ran the app from Xcode.
  • 从Xcode跑出应用程序。

Result: This worked; my changed strings showed up in the running application.

结果:这有效;我更改的字符串出现在正在运行的应用程序中

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:

但我想成为所有人。我想使用.strings文件进行法语本地化。 (这不仅仅是一种幻想;法语本地化将转交给非技术翻译人员,他们不能指望他们掌握Interface Builder。)所以:

  • Selected the base MainStoryboard.storyboard in the Xcode Project navigator.
  • 在Xcode项目导航器中选择了基本MainStoryboard.storyboard。

  • In the File inspector, under Localization, changed the French localization from "Interface Builder Cocoa Touch Storyboard" to "Localizable Strings."
  • 在“文件”检查器中的“本地化”下,将“法语本地化”从“Interface Builder Cocoa Touch Storyboard”更改为“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.
  • 接受Xcode的警告,法国故事板将被丢弃,转而使用.strings文件,该文件出现在助理编辑器中。

  • 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.
  • 做了两个相同的编辑;毫无疑问他们是错误的字符串,因为他们都被评为IBUISegmentedControl ... segmentTitles;并且标签文本不会出现在.strings文件中的任何其他位置。

  • 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.

结果:视图使用基本(原始英语)本地化,而不是加载法语字符串。

Converting to Autolayout had no effect. Deleting the app from the simulator had no effect. Deleting the Derived Products directory had no effect. A Stack Overflow suggested using ibtool to generate the .strings file instead of Xcode; the two generated files are identical.

转换为Autolayout没有任何效果。从模拟器中删除应用程序没有任何效果。删除派生产品目录无效。 Stack Overflow建议使用ibtool生成.strings文件而不是Xcode;两个生成的文件是相同的。

This isn't satisfactory. 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?

这不太令人满意。正如我所说,我无法将.storyboard文件转换为非技术翻译。如何让iOS接受.strings文件中的故事板本地化?

4 个解决方案

#1


3  

I hope you have already solved. I had the same problem (with translation in Italian) and I solved it this way:

我希望你已经解决了。我有同样的问题(用意大利语翻译),我这样解决了:

1) File Localizable.string in it.lproj

1)在it.lproj中归档Localizable.string

2) use NSLocalizedString (@ "TEST", @ "comment") method where it needs

2)在需要的地方使用NSLocalizedString(@“TEST”,@“comment”)方法

3) add Localizable.string in Build Phases-> Copy Bundle Resource The last step is not neccesary in iOS 5.1.

3)在Build Phases-> Copy Bundle Resource中添加Localizable.string在iOS 5.1中不需要最后一步。

I solved thanks to the response of Cocoanetics in [question]:Base internationalization and multiple storyboard not working right

我解决了Cocoanetics在[问题]中的反应:基础国际化和多个故事板不能正常工作

#2


4  

Enable the English localization checkbox, using the Localization Strings setting:

使用“本地化字符串”设置启用英语本地化复选框:

基本本地化+故事板+ .strings  - >没有本地化

Clean your build folder (⌥⇧⌘K) and rebuild.

清理构建文件夹(⌥⇧⌘K)并重建。

#3


1  

To add onto claymation's answer about doing a clean build, it also helps to delete the app from the iOS Simulator.

要添加到claymation关于执行干净构建的答案,还有助于从iOS模拟器中删除应用程序。

It may be related to what John Hess's answer describes.

这可能与John Hess的回答描述有关。

#4


1  

Had to convert my strings file into a storyboard then back into a strings file to get this to work. Ridiculous. Apple could learn a thing or two from Microsoft about creating more reliable developer tools.

不得不将我的字符串文件转换为故事板然后返回到字符串文件中以使其工作。荒谬。 Apple可以从微软那里学到一些关于创建更可靠的开发人员工具的知识。

#1


3  

I hope you have already solved. I had the same problem (with translation in Italian) and I solved it this way:

我希望你已经解决了。我有同样的问题(用意大利语翻译),我这样解决了:

1) File Localizable.string in it.lproj

1)在it.lproj中归档Localizable.string

2) use NSLocalizedString (@ "TEST", @ "comment") method where it needs

2)在需要的地方使用NSLocalizedString(@“TEST”,@“comment”)方法

3) add Localizable.string in Build Phases-> Copy Bundle Resource The last step is not neccesary in iOS 5.1.

3)在Build Phases-> Copy Bundle Resource中添加Localizable.string在iOS 5.1中不需要最后一步。

I solved thanks to the response of Cocoanetics in [question]:Base internationalization and multiple storyboard not working right

我解决了Cocoanetics在[问题]中的反应:基础国际化和多个故事板不能正常工作

#2


4  

Enable the English localization checkbox, using the Localization Strings setting:

使用“本地化字符串”设置启用英语本地化复选框:

基本本地化+故事板+ .strings  - >没有本地化

Clean your build folder (⌥⇧⌘K) and rebuild.

清理构建文件夹(⌥⇧⌘K)并重建。

#3


1  

To add onto claymation's answer about doing a clean build, it also helps to delete the app from the iOS Simulator.

要添加到claymation关于执行干净构建的答案,还有助于从iOS模拟器中删除应用程序。

It may be related to what John Hess's answer describes.

这可能与John Hess的回答描述有关。

#4


1  

Had to convert my strings file into a storyboard then back into a strings file to get this to work. Ridiculous. Apple could learn a thing or two from Microsoft about creating more reliable developer tools.

不得不将我的字符串文件转换为故事板然后返回到字符串文件中以使其工作。荒谬。 Apple可以从微软那里学到一些关于创建更可靠的开发人员工具的知识。