본문으로 건너뛰기
cccskills
무료GitHub에 공개

language-injection

Guides developers in making agent replies and interface messages follow each user's language settings. It covers language instructions in prompts, frontend translation keys, and adding languages through the application's existing shared modules.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

원문원문 설명 보기

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

설치 방법 보기

이럴 때 유용합니다

  • Making agent replies follow the user's language
  • Translating backend messages for the interface
  • Adding support for another language
  • Reviewing language handling in new agent endpoints

포함된 파일(1)

  • SKILL.md5.1 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

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

ModuleRole
agents/agent_language.pybuild_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

# In a Flask route handler:
lang_instruction = get_language_instruction(mode="compact")
lang_suffix = f"\n\n{lang_instruction}" if lang_instruction else ""

messages = [
    {"role": "system", "content": "You are a helpful assistant." + lang_suffix},
    {"role": "user", "content": user_input},
]

Agent constructor — use inject_language_instruction()

from data_formulator.agents.agent_language import inject_language_instruction

# Simple append (most agents)
system_prompt = inject_language_instruction(system_prompt, language_instruction)

# Insert before a marker (complex prompts)
system_prompt = inject_language_instruction(
    system_prompt, language_instruction,
    marker="**About the execution environment:**"
)

Python-side user-visible messages — message_code pattern

For fixed strings in Python that appear in the UI, do NOT translate in Python. Return a message_code and let the frontend translate:

# In an Agent or route handler:
yield {
    "type": "error",
    "message": "Output DataFrame is empty (0 rows).",  # English fallback
    "message_code": "agent.emptyDataframe",             # frontend i18n key
}

# With parameters:
result = {
    "status": "error",
    "content": f"Fields not found: {missing}",
    "content_code": "agent.fieldsNotFound",
    "content_params": {"missing": missing, "available": available},
}

Frontend consumption:

import { translateBackend } from '../app/utils';
const msg = translateBackend(event.message, event.message_code, event.message_params);

Translation keys go in src/i18n/locales/{en,zh}/messages.json under messages.agent.*.

Anti-Patterns (with explanations)

PatternWhy it's wrong
os.environ.get("DF_DEFAULT_LANGUAGE")Process-level — all users get same language; breaks multi-user
Global LLM client interceptorHidden behavior; can't distinguish full/compact mode; fragile string detection
New MessageBuilder classDuplicates agent_language.py; creates parallel conflicting abstractions
Hardcoded "回答请使用中文" in promptsNot configurable; skips the mode system; breaks for other languages
Backend-side translation dict (agent_messages.py)Forces adding every new language to Python; translations should all live in src/i18n/locales/
Hardcoded English UI strings in .tsx without t()Not translatable; use useTranslation + t('key')

Adding a New Language

  1. Add language code + display name to LANGUAGE_DISPLAY_NAMES in agents/agent_language.py.
  2. Optionally add extra rules to LANGUAGE_EXTRA_RULES (e.g. simplified vs traditional Chinese).
  3. Add frontend translations in src/i18n/locales/<lang>/ — copy an existing locale folder as template.
  4. No Agent code changes needed — the existing flow picks up new languages automatically.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

core

무료

Supports analysis of tables already in the workspace through data inspection, Python calculations, and charts chosen for the question. It also explains how to ask users for clarification and label results with meaningful units and names.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Inspecting table columns, statistics, and sample rows
  • Comparing categories or tracking changes over time
  • Exploring distributions and relationships
microsoft/data-formulator1.8만2026년 10월 17일 업데이트

Find missing data in connected sources, inspect table structure, and suggest loading options for analysis. It also helps prepare a connection form for a new source, leaving connection and loading choices to the user.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Find external tables needed for an analysis
  • Browse available connected data sources
  • Check table columns before choosing data
microsoft/data-formulator1.8만2026년 10월 17일 업데이트

Guides developers in handling API failures consistently from backend responses to frontend messages. It covers ordinary and streaming requests, translated error codes, retry and authentication handling, request identifiers, and removing credentials from server logs.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Adding an API endpoint with consistent error responses
  • Displaying errors during streaming responses
  • Adding error codes and translated messages
microsoft/data-formulator1.8만2026년 10월 17일 업데이트

Guides developers in restricting server file access to approved directories. It covers validated download paths, agent file tools, local data connectors, and sandbox settings to address path traversal, where supplied paths escape their allowed location.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Reviewing file download routes
  • Restricting agent file access to a workspace
  • Checking local file connectors for cloud deployment
microsoft/data-formulator1.8만2026년 10월 17일 업데이트

report

무료

Turn data exploration findings into one Markdown report with embedded charts and tables. Adapt the structure for a short summary, blog post, executive briefing, KPI overview, or detailed analysis while checking supporting data.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Summarize analysis findings for management
  • Write a blog post with supporting charts
  • Compile a KPI overview with commentary
microsoft/data-formulator1.8만2026년 10월 17일 업데이트

microsoft의 스킬 모두 보기

이 스킬의 문제 신고