【问题标题】:How can I limit a Weblate check/autofix on the file format (i.a. Android, iOS)如何限制 Weblate 检查/自动修复文件格式(即 Android、iOS)
【发布时间】:2020-09-24 14:59:21
【问题描述】:

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

现在我想改进工作流程。

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

目前使用的占位符是 %1$@ 用于 iOS 和 %1$s 用于 Android

我的问题:

  • 是否有更好/通用的方法可以教我的翻译人员如何编写占位符?
  • 如何根据文件格式(或翻译文件后缀,即 .xml、.strings)编写支票?所以我知道,这是一个android/xml文件,占位符应该是%1$s NOT %1$@

样品检查

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
...

提前致谢

【问题讨论】:

    标签: android ios localization weblate


    【解决方案1】:

    我可以看到几种方法:

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

    【讨论】:

      猜你喜欢
      • 2013-05-02
      • 2022-01-26
      • 1970-01-01
      • 2016-12-11
      • 2019-10-20
      • 2021-01-04
      • 2022-01-19
      • 2021-04-28
      相关资源
      最近更新 更多