# Ported from alibaba/open-code-review (Apache-2.0):
#   internal/config/rules/rule_docs/po.md
#   at commit 89ec55b14442c9f2601fb55b5f554fb6fabbe2c7.
# OCR tool names were replaced with this workflow's read-only
# exploration language. See the NOTICE.md and LICENSE files
# in rules/builtin/ for attribution and license details.
version: 1

rules:
  - id: format.po
    description: "> Favor precision over recall: only raise an issue when you are confident it is a real defect, and stay silent when the surrounding context is unclear — a false alarm costs more reviewer trust than a missed minor issue. Treat factual errors and placeholder mismatches as blocking, and style suggestions as non-blocking."
    match:
      paths:
        - "**/*.po"
    checks:
      - id: factual-errors-in-translation
        category: correctness
        guidance: |
          - The `msgstr` contradicts or distorts the meaning of its `msgid` (mistranslation, omitted clauses, or text belonging to a different entry)
          - Numbers, units, dates, or proper nouns in the `msgstr` that do not match the `msgid` (e.g., "100 MB" translated as "100 GB")
          - Do not report subjective wording preferences, tone, or regional variants when the meaning is preserved
      - id: format-and-structure
        category: correctness
        guidance: |
          - Unbalanced or unescaped quotes in `msgid`/`msgstr` strings, breaking the entry
          - Multi-line continuation strings concatenated incorrectly (missing trailing space/newline between fragments that changes the resulting text)
          - `msgstr` missing entirely for a non-fuzzy entry, or orphaned `msgstr` without a preceding `msgid`
          - Duplicate `msgid` definitions within the file that conflict with each other
      - id: placeholder-mismatch
        category: correctness
        guidance: |
          - Format placeholders (`%s`, `%d`, `%.2f`, `%(name)s`) present in the `msgid` but missing, reordered (without positional markers like `%1$s`), or changed in type in the `msgstr`
          - Named placeholders renamed in the `msgstr` (e.g., `%(user)s` becoming `%(name)s`), which breaks lookups at runtime
          - Brace-style placeholders (`{0}`, `{name}`, `{{count}}`) whose count or names differ between `msgid` and `msgstr`
          - Do not report reordering that is correctly expressed with explicit positional markers
      - id: plural-forms
        category: correctness
        guidance: |
          - Number of `msgstr[n]` entries does not match the `nplurals` declared in the `Plural-Forms` header
          - `msgid_plural` present but only `msgstr[0]` provided, or `msgstr[n]` indices that skip values
          - A language whose plural rules require multiple forms (e.g., Arabic, Russian, Polish) given a single form that copies the singular, when the count varies
      - id: escapes-and-surrounding-whitespace
        category: correctness
        guidance: |
          - Broken escape sequences (`\n`, `\t`, `\"`) that render literally or terminate the string early
          - Leading/trailing whitespace or trailing `\n` present in the `msgid` but missing (or added) in the `msgstr`, causing layout or concatenation differences
          - Encoding-corrupted characters (mojibake) in the `msgstr`
