如何使用 NSPredicateEditorRowTemplate 进行本地化
它没有很好的记录,弄清楚它是一件非常痛苦的事情。
一切都是以编程方式编写的
我想要法语、意大利语版本等。
如何使用 NSPredicateEditorRowTemplate 进行本地化
它没有很好的记录,弄清楚它是一件非常痛苦的事情。
一切都是以编程方式编写的
我想要法语、意大利语版本等。
本地化 NSPredicateEditor 比通常的本地化要复杂一些。
首先,您需要在代码中的某个地方调用 NSLocalizedString() 以便 genstrings 能够找到它们。
其次,密钥需要遵循一种特殊的格式,该格式将指示 genstrings 生成给定行的所有组合:
NSLocalizedStringFromTable(@"%[Any, All, None]@ of the following are true", @"Predicate", @"localize the compound row template")
NSLocalizedStringFromTable(@"%[property]@ %[is, is not, contains, begins with, ends with, like, matches]@ %@", @"Predicate", @"localize the string row template")
NSLocalizedStringFromTable(@"%[birthMonth]@ %[is, is not]@ %[January, February, March, April, May, June, July, August, September, October, November, December]@", @"Predicate", @"localize the selection row template")
在上面的示例中,genstrings 将查看括号之间的选项并为 Predicate.strings 文件中的所有组合生成本地化字符串。
最后,您必须通过设置formattingStringsFilename
属性让您的 NSPredicateEditor 实例知道要使用哪个字符串文件。
有关更多信息,请参阅此博客文章。
该博客已有几年历史了。
xcode 多年来一直在改进。
这个问题是重复的,但几年后答案可能会有所不同。
答案很简单。它是 xib 文件的本地化,它工作得很好