Skip to main content

用于检查 CommCare 应用程序的批量翻译文件在翻译中是否具有一致的 <output value.../> 标签的命令行工具。

项目描述

CommcareTranslationChecker

https://github.com/dimagi/CommcareTranslationChecker

一个命令行工具,用于检查批量翻译文件的多个列,以确保在列之间一致地使用输出值标签。

安装

0a。安装 Python 和pip. 此工具已使用 Python 2.7 和 3.6 进行了测试。

1. 通过安装 CommCare Translation Checkerpip

$ pip install CommcareTranslationChecker

基本命令行用法

命令行工具的基本用法是保存 Excel 文件。这可以配置为表单翻译应用程序翻译

$ CommcareTranslationChecker  <relative or absolute path to translation file>

默认情况下,这将读取指定的文件,并检查名称以“default_”开头的所有列与最左边的“default_”列。如果在任何列中的“输出值”标签列表之间发现任何差异,则会在文件夹“commcareTranslationChecker_output”中生成一个文件。如果相对于当前路径不存在这样的文件夹,则会创建该文件夹。该文件将是输入文件中数据的精确副本,每个工作表都附加了一个附加列“mismatchFlag”。该列将在检测到差异的所有行中标记为“Y”,否则标记为“N”。此外,“输出值”标签与最左侧列不同的所有单元格都将被红色填充,以便于视觉参考。

如果翻译文件包含名为 Modules_and_forms 的工作表和名为 sheet_names 的列,则该工具将检查该列中的每个值是否对应于工作簿中一张工作表的名称。如果不是,则输出文件的 sheet_names 列中的相应单元格将突出显示为红色。

创建文件后,将打印一份摘要,概述每张纸上发现有多少行存在差异。

通过导入使用

>>> import openpyxl
>>> from CommcareTranslationChecker import validate_workbook
>>> messages = []
>>> wb = openpyxl.load_workbook("examples/TranslationCheckerTest_BulkAppTranslation.xlsx")
>>> validate_workbook(wb, messages)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "CommcareTranslationChecker/CommcareTranslationChecker.py", line 527, in validate_workbook
    raise FatalError("Some fatal error message.")
CommcareTranslationChecker.exceptions.FatalError: Some fatal error message.
>>> messages
['There were issues with the following worksheets:', u'moduleX_formY is missing from the workbook.']

高级命令行用法

除了概述的基本用法外,还有许多可选参数可以提供更加定制化的体验。

$ CommcareTranslationChecker    --columns <comma-separated list of column names to check> \
                                --base-column <name of column to be compared against, if different from left-most> \
                                --output-folder <relative or absolute path to folder in which to save output file> \
                                --ignore-order \
                                --verbose \
                                --no-output-file \
                                --configuration-sheet <name of sheet containing meta information about other sheets in the workbook> \
                                --configuration-sheet-column <name of column in configuration-sheet containing expected sheet titles> \
                                --output-mismatch-types \
                                --format-check \
                                --format-check-characters <sequence of characters whose counts will be compared by format check> \
                                --format-check-characters-add <sequence of characters to add to the current format check character list> \

                                

不包含输入参数的五个选项如下所述:

  • --ignore-order如果通过,则在将单元格相互比较时将不考虑输出值标签出现的顺序。如果由于所涉及的语言之间的词序不同,列之间的输出值标签的顺序不同,这将很有用。
  • --verbose如果通过,输出将打印到屏幕上,指出文件的哪些行有问题。
  • --no-output-file如果通过,则不会创建输出文件。
  • --output-mismatch-types如果通过,将在输出中包含有关不匹配的更多信息。如果生成输出文件,则此信息将作为包含错误的每个语言列的每个工作表上的附加列附加。如果传递了--verbose标志,则此信息将添加到每一行输出中。
  • --format-check如果通过,将添加一个额外的检查来比较列之间任何特殊字符的计数。默认字符列表为 ~`!@#$%^&*()_-+={[}]|\:;"'<,>.?/

查看CommcareTranslationChecker --help完整的选项列表。

发布流程

1.为发布创建标签

$ git tag -a "X.YY.0" -m "Release X.YY.0"
$ git push --tags

2.创建源分布

确保存档具有正确的版本号(与标签名称匹配)。

$ python setup.py sdist

3. 创建轮子

$ python setup.py bdist_wheel --universal

4.上传到pypi

$ pip install twine
$ twine upload dist/CommcareTranslationChecker-X.YY.0*

5.验证上传

https://pypi.python.org/pypi/CommcareTranslationChecker

6.在github上创建一个release

https://github.com/dimagi/CommcareTranslationChecker/releases

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

CommcareTranslationChecker-0.9.7.ta​​r.gz (15.6 kB 查看哈希

已上传 source