gpt4 book ai didi

swift - 在 NSLocalizedString 中设置 tableName 参数时,genstrings 不起作用

转载 作者:行者123 更新时间:2023-11-28 06:53:58 24 4
gpt4 key购买 nike

我得到 Bad entry in file使用 genstrings 时出错每次调用 NSLocalizedString 的命令行使用tableName参数

尝试生成本地化字符串时请参阅以下示例(来自 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 中但在运行时,应用程序不显示本地化标题,因为它试图从名称为 Storage.strings 的文件中加载本地化字符串。不是来自 Localizable.strings

是否有任何解决方案可以自动生成这些文件而不是手动生成?

最佳答案

看来我需要按照apple的最新流程翻译资源

  1. 使用 Xcode 导出本地化文件 .xliff(在 Xcode 中选择您的项目,然后选择 Editor -> Export for Localization)
  2. 使用翻译工具翻译所有键(SwordFishbrightec online xliff editor)
  3. 将翻译后的文件导入回 Xcode

引用: https://developer.apple.com/library/ios/documentation/MacOSX/Conceptual/BPInternational/LocalizingYourApp/LocalizingYourApp.html

关于swift - 在 NSLocalizedString 中设置 tableName 参数时,genstrings 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34198743/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com