在 NSLocalizedString 中设置 tableName 参数时,genstrings 不起作用
genstrings does not work when setting tableName parameter in NSLocalizedString
每次使用 genstrings
命令行调用使用 tableName
参数
的 NSLocalizedString
时,我都会收到 Bad entry in file
错误
尝试生成本地化字符串时请参阅以下示例(来自 Firefox-iOS)
find . -name *.swift | xargs genstrings -o en.lproj
Bad entry in file ./StorageTests/TestSQLiteHistory.swift (line = 100): Argument is not a literal string.
Bad entry in file ./StorageTests/TestSQLiteHistory.swift (line = 101): Argument is not a literal string.
Bad entry in file ./StorageTests/TestSQLiteHistory.swift (line = 102): Argument is not a literal string.
Bad entry in file ./StorageTests/TestSQLiteHistory.swift (line = 103): Argument is not a literal string. Argument is not a literal string.
这是这些行的代码
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
中,但在 运行 时间内应用程序不显示本地化标题,因为它试图从名称为 [ 的文件中加载本地化字符串=17=] 不是来自 Localizable.strings
是否有任何解决方案可以自动生成这些文件而不是手动生成?
看来我需要按照apple的最新流程翻译资源
- 使用 Xcode 导出本地化文件
.xliff
(select 您在 Xcode 中的项目,然后是编辑器 -> 导出以进行本地化)
- 使用翻译工具翻译所有按键(SwordFish, brightec online xliff editor)
- 将翻译后的文件导入回 Xcode
每次使用 genstrings
命令行调用使用 tableName
参数
NSLocalizedString
时,我都会收到 Bad entry in file
错误
尝试生成本地化字符串时请参阅以下示例(来自 Firefox-iOS)
find . -name *.swift | xargs genstrings -o en.lproj
Bad entry in file ./StorageTests/TestSQLiteHistory.swift (line = 100): Argument is not a literal string.
Bad entry in file ./StorageTests/TestSQLiteHistory.swift (line = 101): Argument is not a literal string.
Bad entry in file ./StorageTests/TestSQLiteHistory.swift (line = 102): Argument is not a literal string.
Bad entry in file ./StorageTests/TestSQLiteHistory.swift (line = 103): Argument is not a literal string. Argument is not a literal string.
这是这些行的代码
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
中,但在 运行 时间内应用程序不显示本地化标题,因为它试图从名称为 [ 的文件中加载本地化字符串=17=] 不是来自 Localizable.strings
是否有任何解决方案可以自动生成这些文件而不是手动生成?
看来我需要按照apple的最新流程翻译资源
- 使用 Xcode 导出本地化文件
.xliff
(select 您在 Xcode 中的项目,然后是编辑器 -> 导出以进行本地化) - 使用翻译工具翻译所有按键(SwordFish, brightec online xliff editor)
- 将翻译后的文件导入回 Xcode