# How the Patent Disclosure Skill Manages Language Switching: Chinese Outputs vs. English Internal Fields

> Discover how the Patent Disclosure Skill handles language switching. Learn how English internal fields support dynamic Chinese outputs via a dedicated presentation layer.

- Repository: [handsomestWei/patent-disclosure-skill](https://github.com/handsomestWei/patent-disclosure-skill)
- Tags: internals
- Published: 2026-09-02

---

**The Patent Disclosure Skill maintains strictly English internal field names while dynamically rendering user-facing content in Simplified Chinese or other requested languages through a dedicated presentation layer.**

The handsomestWei/patent-disclosure-skill implements a **separation of concerns** architecture that keeps machine-readable data contracts stable while supporting seamless multilingual presentation. This design ensures that downstream automation scripts can reliably parse JSON outputs regardless of the display language selected by the user.

## Default Language Configuration

According to [`SKILL.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/SKILL.md) (line 50), the skill defaults to **Simplified Chinese** (`zh-CN`) for all user-facing content. This includes search result lists, disclosure drafts, analysis reports, and examiner response templates.

The default configuration is stored in [`tools/oa/config.py`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/tools/oa/config.py), where the `language` parameter initializes to `zh-CN` unless explicitly overridden. When processing begins, the language selector inspects the incoming request for a `language` key or a `--lang` command-line argument. If absent, the system immediately falls back to Chinese output generation.

## Internal Field Stability Guarantee

All **internal fields** remain strictly English to ensure cross-language compatibility and reliable downstream processing. As documented in [`SKILL.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/SKILL.md) (line 229), the following elements never change regardless of the presentation language:

- **JSON keys**: Data structure identifiers remain in English (e.g., `epub_hits_json`, `docx`, `status`)
- **Script prefixes**: Output markers like `EPUB_HITS_JSON:`, `MERMAID:`, and `DOCX:` are hardcoded in English
- **Status codes**: Internal enumerations and error codes use English identifiers

Core modules located in `tools/oa/*` and `tools/shared/*` perform all data gathering, analysis, and generation using these English-named JSON structures. For example, [`tools/shared/mermaid_render.py`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/tools/shared/mermaid_render.py) emits diagrams prefixed with `MERMAID:` regardless of the user's language preference.

## The Presentation Layer and Translation Mechanism

The translation occurs at the **formatter layer** after core logic completes. This layer reads the selected language, pulls the appropriate translation map, and replaces only user-visible strings while leaving internal keys untouched.

The translation mechanism relies on two components:

- **[`lang_map.yaml`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/lang_map.yaml)**: A lookup table containing translations for field labels, table headers, and status messages
- **`prompts/` directory**: Language-specific templates stored under `prompts/search/`, `prompts/analysis/`, and similar subdirectories

When `apply_language()` processes the output, it maps English internal values to localized display strings. For instance, the internal boolean `ok` becomes `成功` (Success) in Chinese output or remains `Success` in English output, while the underlying JSON key stays `ok`.

## Language Override Implementation

Users can trigger language switching through two mechanisms defined in [`SKILL.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/SKILL.md) (line 229):

1. **Command-line flag**: Passing `--lang en` or `--lang ja` to the main entry script
2. **JSON payload**: Including a `"language": "en"` key in the input JSON

The [`run_skill.py`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/run_skill.py) entry point extracts this parameter and passes it to the formatter. The following Python pattern from [`utils/language.py`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/utils/language.py) illustrates the implementation:

```python

# utils/language.py – core language handling

LANG_MAP = {
    "zh-CN": {
        "header": "专利检索清单",
        "status_ok": "成功",
        "status_fail": "失败",
    },
    "en": {
        "header": "Patent Search List",
        "status_ok": "Success",
        "status_fail": "Failure",
    },
}

def apply_language(data: dict, lang: str = "zh-CN") -> dict:
    """
    Convert user-visible fields to the requested language while leaving
    internal keys (e.g., epub_hits_json, docx) untouched.
    """
    mapping = LANG_MAP.get(lang, LANG_MAP["zh-CN"])
    # Translate only the top-level display fields

    data["display_header"] = mapping["header"]
    data["status"] = mapping["status_ok"] if data["ok"] else mapping["status_fail"]
    return data

# Entry point – run_skill.py

import json, sys
from utils.language import apply_language

payload = json.loads(sys.stdin.read())
lang = payload.get("language", "zh-CN")      # defaults to Chinese

result = core_logic(payload)                # returns internal JSON with English keys

localized = apply_language(result, lang)

print(json.dumps(localized, ensure_ascii=False))

```

The `core_logic()` function always produces English-keyed JSON structures. The `apply_language()` wrapper then injects localized strings only into display-oriented fields, preserving the internal data contract for downstream processing.

## Safety Guards and Fallback Behavior

As documented in [`README.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/README.md) (line 104), the skill implements strict safety guards to prevent internal leakage:

- **No raw key emission**: The formatter never exposes internal English keys directly to end users
- **Graceful degradation**: If a user requests an unsupported language (e.g., `"language": "fr"` when French mappings don't exist), the system falls back to Simplified Chinese output while retaining English internal keys for downstream processing
- **Validation layer**: Input sanitization ensures that only whitelisted language codes pass through to the formatter

This architecture guarantees that automation scripts consuming the JSON output can always rely on English field names (`EPUB_HITS_JSON:`, `docx`, `ok`) while human users see fully localized content.

## Summary

- **Default behavior**: All user-facing content renders in Simplified Chinese (`zh-CN`) per [`SKILL.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/SKILL.md) configuration
- **Internal stability**: JSON keys, script prefixes, and status codes remain permanently English to ensure machine-readable contracts
- **Presentation separation**: Translation occurs post-processing via `apply_language()` using [`lang_map.yaml`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/lang_map.yaml) and `prompts/` templates
- **Override methods**: Users specify alternatives via `--lang` flags or JSON `language` keys
- **Fallback protection**: Unsupported languages default back to Chinese rather than exposing raw internal fields

## Frequently Asked Questions

### What happens if I request a language that isn't supported?

The skill falls back to Simplified Chinese output while maintaining English internal keys. According to [`README.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/README.md) (line 104), this safety guard prevents the system from emitting untranslated internal field names or error states when translation mappings are missing from [`lang_map.yaml`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/lang_map.yaml).

### Are internal JSON keys ever translated to Chinese or other languages?

No. Internal fields including JSON keys, script prefixes like `EPUB_HITS_JSON:` and `MERMAID:`, and status codes remain strictly English as implemented in `tools/oa/*` and `tools/shared/*`. Only the presentation layer translates user-visible labels and messages.

### How do I programmatically change the output language?

Pass a `language` key in your JSON input payload (e.g., `{"language": "en", "query": "..."}`) or use the `--lang` command-line argument when executing [`run_skill.py`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/run_skill.py). The language selector in the entry point detects these parameters and routes the output through the appropriate translation map.

### Which files control the translation mappings?

The primary translation logic resides in [`utils/language.py`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/utils/language.py) (containing `apply_language()` and `LANG_MAP`), while [`lang_map.yaml`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/lang_map.yaml) stores the string lookup tables. Language-specific prompt templates are located in the `prompts/` directory subfolders, and default configurations are defined in [`tools/oa/config.py`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/tools/oa/config.py).