macos - 本地化 NSPredicateEditor / 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 实例知道要使用哪个字符串文件。
有关更多信息,请参阅此博客文章。
推荐阅读
- android - 如何从布局约束部分的第一个应用程序 Android 教程中解除阻塞
- python - 错误:object_detection.utils ModuleNotFoundError
- angular8 - Angular google maps + PlacesService + 无法在结果中获取经纬度信息
- python - Python pandas - 对列值求和并创建字典
- vb.net - 我如何让用户输入一个数字,如果用户输入一个字母,它会返回一个错误 - VB.net
- android - Stepper 中的内联 TextFormField
- python - 灰屏显示和无法播放的文件opencv2-python
- javascript - 地图数组内的地图数组
- c++ - 将向量作为值分配给 std::unordered_map 中的键
- nginx - 为什么会触发 https 重定向?