如何限制 Weblate check/autofix 的文件格式 (i.a. Android, iOS)

How can I limit a Weblate check/autofix on the file format (i.a. Android, iOS)

我们在我们的移动应用程序 CI 环境中使用 Weblate。到目前为止,一切都很棒。 Weblate 在 docker 环境中运行 (v4.1)

现在我想改进工作流程。

我设法创建了自定义检查,这些检查验证了 Android/iOS 占位符的使用(请参见下面的示例)。现在翻译者需要知道他正在使用哪个平台来使用正确的占位符并消除误报检查。

现在使用的占位符是 %1$@ 代表 iOS 和 %1$s 代表 Android

我的问题:

样本检查

class iOSPlaceholderCheck(TargetCheck):
    # Used as identifier for check, should be unique
    # Has to be shorter than 50 characters
    check_id = "iOSPlaceholder"

    # Short name used to display failing check
    name = _("iOS placeholder")

    # Description for failing check
    description = _("Your translation contains an iOS placeholder")

    # Real check code
    def check_single(self, source, target, unit):
        if "%1$@" in target:
            return True
...

提前致谢

我能看到几个方法:

  • 如果这些格式对文件格式通用,file a feature request 以便它包含在未来的 Weblate 版本中
  • 如果这只影响几个字符串,您可以定义占位符,您可以利用 generic placeholders 检查 Weblate 并让 Weblate 检查并突出显示它们
  • 要限制检查仅在某些组件上触发,您可以使用translation flags,这些可以在组件级别设置
  • 如果您想编写自定义检查,它可能还应该检查源字符串中是否存在格式字符串,例如:
if "%1$@" not in source:
    return False
return "%1$@" not in target