【问题标题】:genstrings does not work when setting tableName parameter in NSLocalizedString在 NSLocalizedString 中设置 tableName 参数时,genstrings 不起作用
【发布时间】: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


    【解决方案1】:

    看来我需要按照苹果最新的程序来翻译资源

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

    参考: https://developer.apple.com/library/ios/documentation/MacOSX/Conceptual/BPInternational/LocalizingYourApp/LocalizingYourApp.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多