compare-locales 编辑

compare-locales is a Python script that helps localizers to check their work without running Firefox or another application.

If you want to run compare-locales on Windows, be sure to first install MozillaBuild.

Installation

compare-locales needs to be installed, and it requires that you have Python 2.7 or 3.5+ installed on your machine. The easiest way is to just run

$ pip install -U compare-locales

Running it

compare-locales gathers the directories to compare from a TOML file, usually found in $APP/locales/l10n.toml. The details of the configuration file are described in the l10n-config docs. You pass the path to the toml file and the parent dir of the localizations as first arguments, followed by the locale codes of the locales you want to compare. If you want to test the localization for de, run

$ compare-locales browser/locales/l10n.toml ./l10n/ de

To check mobile, replace the previous line with:

$ compare-locales mobile/android/locales/l10n.toml ./l10n/ zh-TW

To check mail, suite, calendar that lives on comm-central,  you can either rely on the check-out of mozilla within comm-central repository that the regular comm-central build instructions generate:

$ compare-locales ./comm-central/mail/locales/l10n.toml ./l10n/ zh-TW

If you don't want to use a copy of mozilla-central in comm-central, you can run them separately:

$ compare-locales -Dmozilla=$PWD/mozilla-central comm-central/mail/locales/l10n.toml ./l10n/ zh-TW

If you're working on multiple projects in parallel, you can also pass all the toml files to compare-locales at once. To get a single result across the projects, specify the --unified flag:

$ compare-locales --unified browser/locales/l10n.toml mobile/android/locales/l10n.toml ./l10n/ de

Cross-channel and compare-locales

If you're working against the gecko-strings cross-channel repository, the toml configuration files are in the _configs subdirectory, browser.toml, mobile_android.toml, mail.toml and calendar.toml, and suite.toml.

Options

To get a brief list of available options, use the --help flag:

$ compare-locales --help

The output

The output of compare-locales shows the missing and obsolete strings in a pseudo-diff format.

ab-CD
  browser
    chrome/browser
      browser.dtd
          +backForwardMenu.tooltip
          +fullZoomEnlargeCmd.commandkey3
          +fullZoomReduceCmd.commandkey2
          +fullZoomResetCmd.commandkey2
          +organizeBookmarks.label
          -showAllBookmarksCmd2.label
      migration/migration.dtd
          -importFromFile.accesskey
          -importFromFile.label
          +importFromHTMLFile.accesskey
          +importFromHTMLFile.label

You can assume changed strings when you see entities removed and added with a similar name. The file names will be shown in a hierarchical form, so in the example above, your files are browser.dtd in ab-CD/browser/chrome/browser and migration.dtd in another directory level deeper.

The output closes with a summary, giving the total counts of missing and obsolete strings and words, and some statistics on how many strings are changed or not, excluding access- and commandkeys. That gives localizers an idea on how thorough the localization is. This number won't reach 100% in general, mid 80s should be the target, though.

Pass --json to get just the summary in JSON format.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:142 次

字数:4503

最后编辑:7 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文