【发布时间】:2015-12-10 09:58:56
【问题描述】:
每次使用tableName 参数调用NSLocalizedString 时使用genstrings 命令行时,我收到Bad entry in file 错误
尝试生成本地化字符串时请参见以下示例(来自Firefox-iOS)
find . -name *.swift | xargs genstrings -o en.lproj
文件 ./StorageTests/TestSQLiteHistory.swift 中有错误条目(行 = 100):参数不是文字字符串。
文件 ./StorageTests/TestSQLiteHistory.swift 中的错误条目(行 = 101):参数不是文字字符串。
文件 ./StorageTests/TestSQLiteHistory.swift 中的错误条目(行 = 102):参数不是文字字符串。
文件 ./StorageTests/TestSQLiteHistory.swift 中的错误条目(行 = 103):参数不是文字字符串。参数不是文字字符串。
这是这些行的代码
let titleMobile = NSLocalizedString("Mobile Bookmarks", tableName: "Storage", comment: "The title of the folder that contains mobile bookmarks. This should match bookmarks.folder.mobile.label on Android.")
let titleMenu = NSLocalizedString("Bookmarks Menu", tableName: "Storage", comment: "The name of the folder that contains desktop bookmarks in the menu. This should match bookmarks.folder.menu.label on Android.")
let titleToolbar = NSLocalizedString("Bookmarks Toolbar", tableName: "Storage", comment: "The name of the folder that contains desktop bookmarks in the toolbar. This should match bookmarks.folder.toolbar.label on Android.")
let titleUnsorted = NSLocalizedString("Unsorted Bookmarks", tableName: "Storage", comment: "The name of the folder that contains unsorted desktop bookmarks. This should match bookmarks.folder.unfiled.label on Android.")
当我搜索解决方案时,我发现了 tool 用于生成和合并本地化字符串。它适用于这种情况,生成本地化字符串并将其合并到 Localizable.strings 但在运行时应用程序不显示本地化标题,因为它尝试从名称为 Storage.strings 的文件中加载本地化字符串而不是来自 @987654331 @
有没有办法自动生成这些文件而不是手动生成?
【问题讨论】:
标签: swift localization ios9 nslocalizedstring genstrings