# Language Injection

LLM Agent 多语言注入规范。在修改 Agent 提示词、添加新的 Agent 端点、处理用户可见的后端消息（message_code）时使用。

- Repository: https://github.com/microsoft/data-formulator (17644 stars)
- Category: AI and agents
- License: MIT
- Last updated: 2026-10-30
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add microsoft/data-formulator --skill language-injection -g -a claude-code -y`
Codex: `npx skills add microsoft/data-formulator --skill language-injection -g -a codex -y`
Cursor: `npx skills add microsoft/data-formulator --skill language-injection -g -a cursor -y`
Gemini CLI: `npx skills add microsoft/data-formulator --skill language-injection -g -a gemini-cli -y`

## Description

LLM Agent 多语言注入规范。在修改 Agent 提示词、添加新的 Agent 端点、处理用户可见的后端消息（message_code）时使用。

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Language Injection for Agent Prompts

Authoritative developer guide: `docs/dev-guides/6-i18n-language-injection.md`.

> **Prerequisites**: Read `docs/dev-guides/6-i18n-language-injection.md` before changing Agent prompts, Agent routes, backend user-visible messages, or frontend i18n strings.
> If your work introduces new language injection patterns or conventions, update this file and related dev-guides accordingly.

## Architecture

```
Frontend i18n.language  →  Accept-Language header  →  get_language_instruction()
                                                           │
                                                   build_language_instruction()
                                                   (agents/agent_language.py)
                                                           │
                                              ┌────────────┴────────────┐
                                              ▼                         ▼
                                        mode="full"               mode="compact"
                                    (text-heavy agents)        (code-gen agents)
```

### Core Modules

| Module | Role |
|--------|------|
| `agents/agent_language.py` | `build_language_instruction(lang, mode)`, generates prompt fragments; `inject_language_instruction()`, injects into system prompts; supports 20 languages; returns `""` for English |
| `routes/agents.py` → `get_language_instruction()` | Reads `Accept-Language` header, delegates to `build_language_instruction` |
| `routes/agents.py` → `_get_ui_lang()` | Extracts primary language code from `Accept-Language` header |
| `src/app/utils.tsx` → `fetchWithIdentity()` | Sets `Accept-Language` header on every API request from `i18n.language` |
| `src/app/utils.tsx` → `translateBackend()` | Translates backend `message_code` / `content_code` using frontend i18n |

## Code Examples

### Route handler, inject language

```python
# In a Flask route handler:
lan

The rest: https://github.com/microsoft/data-formulator/blob/HEAD/.cursor/skills/language-injection/SKILL.md
