App-Greple-xlate

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

    contains `%s`, it will be replaced with the target language name.

- **--xlate-context**=_text_

    Specify additional context information to be sent to the translation
    engine.  This option can be used multiple times to provide multiple
    context strings.  The context information helps the translation engine
    understand the background and produce more accurate translations.

- **--xlate-context-window**=_n_

    (Context-aware engines only, e.g. `gpt5` on the llm backend)
    Number of surrounding translated blocks passed as reference context
    when re-translating changed blocks (default 2).  The context also
    includes the raw source text around the changed region (headings,
    list structure, captions) and, when available, the previous version
    of the changed text recovered from the cache, so that unchanged
    wording is preserved.  Set to 0 to disable context-aware translation
    entirely.
    Note that each changed region is translated in its own API call and
    the context can add up to about 8000 characters to the system
    prompt, so context-aware translation trades some extra cost for
    consistency.

- **--xlate-cache-seed**=_file_

    Initialize a new document's cache from another document's cache
    file.  Useful for periodic reports: seed the new issue's cache with
    the previous issue's, so unchanged paragraphs are not re-translated
    and edited paragraphs keep the previous issue's wording.  The seed
    is used only when the target cache is empty; otherwise it is
    ignored with a warning.  With the default `--xlate-cache=auto`, specifying a seed also
    implies creating the new document's cache file.

- **--xlate-anonymize**=_file_

    Anonymize sensitive strings before they are sent to the translation
    API, and restore them in the output.  The dictionary file gives one
    entry per item: in JSON (canonical, machine-generatable)

        [ { "category": "person",  "text": "山田太郎" },
          { "category": "company", "regex": "アクメ(株式会社)?" } ]

    or in a simple line format (`category pattern`, `/.../` for regex).
    Each item is replaced by a category tag such as `<person id=1 />`;
    the same string always gets the same tag, so the model can keep track
    of who is who.  Unknown JSON fields are ignored, so generators (e.g. a
    local LLM extracting entities) may add their own annotations.
    Category `lit` is reserved.  Local cache files still store restored
    plain text: the concealment target is API transmission only.

    A dictionary can be generated by an external tool -- for example a
    local model extracting sensitive entities:

        llm -m <local-model> \
            -s 'Extract sensitive entities as a JSON array of objects
                with "category" and "text" fields.' \
            < report.md > report.anon.json
        greple -Mxlate --xlate-anonymize=report.anon.json ...

    A UTF-8 BOM in the file is tolerated.  Values in the front matter
    line format may carry a trailing comment only on their own line, not
    after the value.

- **--xlate-anonymize-mark**\[=_regex_\]

    Collect anonymization entries from inline marks in the document
    itself.  Mark the first occurrence like `{{ person("山田太郎") }}`
    and every occurrence of the string document-wide is anonymized.  The
    mark itself stays in the source and in the translation, so a document
    can also be processed by a Jinja2-style macro processor (define the
    `person` macro to print or redact the name).  A custom _regex_ must
    contain `(?<category>...)` and `(?<text>...)` named captures.

    Note that with an optional-value option like this, a following
    file argument would be taken as the value: write
    `--xlate-anonymize-mark=` (with a trailing `=`) when using the
    default notation.

    Alternative notations can be configured, for example
    `--xlate-anonymize-mark='@@(?<category>[a-z][a-z0-9_]*):(?<text>[^\n]+?)@@'`
    for `@@person:NAME@@`-style marks, or an HTML-comment form that stays
    invisible in rendered Markdown.  Mark rules are collected per
    document: a string marked in one input file is not concealed in
    another file of the same run (unlike front matter values, which
    accumulate across files).

- **--xlate-template**\[=_regex_\]

    Treat template expressions (default: Jinja2 `{{ ... }}`,
    `{% ... %}`, `{# ... #}`) as opaque placeholders: instruct the
    model to copy them unchanged and verify, per block, that the response
    contains exactly the same expressions, each the same number of times.
    Their order may change, since translation legitimately reorders them
    to follow the target language word order.  A broken expression
    aborts the run; the cache is checkpointed and frozen, so nothing paid
    for is lost.

    Note that with an optional-value option like this, a following
    file argument would be taken as the value: write
    `--xlate-template=` (with a trailing `=`) when using the
    default notation.

- **--xlate-frontmatter**

    Treat a leading `---` ... `---` block as YAML front matter: exclude
    it from translation and from the phase-2 context slices, and add its
    flat `key: value` values to the anonymization rules (category
    `var`) as a safety net.  With multiple input files the collected
    values accumulate (erring on the side of concealment).

    Always leave a blank line after the closing `---`.  With a
    paragraph-style match pattern, front matter that runs directly into
    the body text forms one straddling block that the exclusion cannot
    suppress (a warning is printed in that case); the values are still
    anonymized, but the front matter itself would be sent for
    translation.

- **--xlate-glossary**=_glossary_

    Specify a glossary ID to be used for translation.  This option is only



( run in 0.697 second using v1.01-cache-2.11-cpan-9581c071862 )