|
| 1 | +# Multi-Language Output Guide |
| 2 | + |
| 3 | +Configure OpenSpec to generate artifacts in languages other than English. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +OpenSpec can output proposals, specs, designs, and tasks in any language by adding language instructions to your project's `context` configuration. This approach uses the existing config system without requiring any code changes. |
| 8 | + |
| 9 | +## Quick Setup |
| 10 | + |
| 11 | +Add a language instruction to your `openspec/config.yaml`: |
| 12 | + |
| 13 | +```yaml |
| 14 | +schema: spec-driven |
| 15 | + |
| 16 | +context: | |
| 17 | + Language: Portuguese (pt-BR) |
| 18 | + All artifacts must be written in Brazilian Portuguese. |
| 19 | + Use Portuguese technical terminology where appropriate. |
| 20 | +
|
| 21 | + # Your other project context below... |
| 22 | + Tech stack: TypeScript, React, Node.js |
| 23 | +``` |
| 24 | +
|
| 25 | +That's it. All generated artifacts will now be in Portuguese. |
| 26 | +
|
| 27 | +## Language Examples |
| 28 | +
|
| 29 | +### Portuguese (Brazil) |
| 30 | +
|
| 31 | +```yaml |
| 32 | +context: | |
| 33 | + Language: Portuguese (pt-BR) |
| 34 | + All artifacts (proposals, specs, designs, tasks) must be written in Brazilian Portuguese. |
| 35 | + Use Brazilian Portuguese conventions for technical terminology. |
| 36 | +``` |
| 37 | +
|
| 38 | +### Spanish |
| 39 | +
|
| 40 | +```yaml |
| 41 | +context: | |
| 42 | + Idioma: Español |
| 43 | + Todos los artefactos deben escribirse en español. |
| 44 | + Utilizar terminología técnica en español cuando sea posible. |
| 45 | +``` |
| 46 | +
|
| 47 | +### Chinese (Simplified) |
| 48 | +
|
| 49 | +```yaml |
| 50 | +context: | |
| 51 | + 语言:中文(简体) |
| 52 | + 所有产出物(提案、规格、设计、任务)必须用简体中文撰写。 |
| 53 | + 技术术语可以保留英文原文,但说明应使用中文。 |
| 54 | +``` |
| 55 | +
|
| 56 | +### Japanese |
| 57 | +
|
| 58 | +```yaml |
| 59 | +context: | |
| 60 | + 言語:日本語 |
| 61 | + すべての成果物は日本語で作成してください。 |
| 62 | + 技術用語は必要に応じて英語を併記可能です。 |
| 63 | +``` |
| 64 | +
|
| 65 | +### French |
| 66 | +
|
| 67 | +```yaml |
| 68 | +context: | |
| 69 | + Langue : Français |
| 70 | + Tous les artefacts doivent être rédigés en français. |
| 71 | + Utiliser la terminologie technique française lorsque possible. |
| 72 | +``` |
| 73 | +
|
| 74 | +### German |
| 75 | +
|
| 76 | +```yaml |
| 77 | +context: | |
| 78 | + Sprache: Deutsch |
| 79 | + Alle Artefakte müssen auf Deutsch verfasst werden. |
| 80 | + Technische Fachbegriffe können auf Englisch beibehalten werden. |
| 81 | +``` |
| 82 | +
|
| 83 | +## How It Works |
| 84 | +
|
| 85 | +The `context` field in `openspec/config.yaml` is injected into every artifact's instructions as an XML block: |
| 86 | + |
| 87 | +```xml |
| 88 | +<context> |
| 89 | +Language: Portuguese (pt-BR) |
| 90 | +All artifacts must be written in Brazilian Portuguese. |
| 91 | +... |
| 92 | +</context> |
| 93 | +
|
| 94 | +<template> |
| 95 | +[Schema's template content] |
| 96 | +</template> |
| 97 | +``` |
| 98 | + |
| 99 | +The AI assistant sees this context when generating any artifact and follows the language instruction. |
| 100 | + |
| 101 | +## Tips |
| 102 | + |
| 103 | +### Be Explicit About Scope |
| 104 | + |
| 105 | +Specify which parts should be in the target language: |
| 106 | + |
| 107 | +```yaml |
| 108 | +context: | |
| 109 | + Language: Spanish |
| 110 | + Write all prose, descriptions, and explanations in Spanish. |
| 111 | + Code comments may remain in English for consistency with the codebase. |
| 112 | + Variable names and code identifiers should stay in English. |
| 113 | +``` |
| 114 | + |
| 115 | +### Handle Technical Terms |
| 116 | + |
| 117 | +Decide how to handle technical terminology: |
| 118 | + |
| 119 | +```yaml |
| 120 | +context: | |
| 121 | + Language: Japanese |
| 122 | + Write in Japanese, but: |
| 123 | + - Keep technical terms like "API", "REST", "GraphQL" in English |
| 124 | + - Provide Japanese explanations in parentheses for complex terms on first use |
| 125 | + - Code examples and file paths remain in English |
| 126 | +``` |
| 127 | + |
| 128 | +### Combine with Other Context |
| 129 | + |
| 130 | +Language settings work alongside your other project context: |
| 131 | + |
| 132 | +```yaml |
| 133 | +schema: spec-driven |
| 134 | +
|
| 135 | +context: | |
| 136 | + Language: Portuguese (pt-BR) |
| 137 | + All artifacts must be written in Brazilian Portuguese. |
| 138 | +
|
| 139 | + Tech stack: TypeScript, React 18, Node.js 20 |
| 140 | + Database: PostgreSQL with Prisma ORM |
| 141 | + Testing: Vitest + React Testing Library |
| 142 | +
|
| 143 | + Conventions: |
| 144 | + - Use functional components with hooks |
| 145 | + - Follow existing patterns in src/components/ |
| 146 | +``` |
| 147 | + |
| 148 | +## Verification |
| 149 | + |
| 150 | +To verify your language config is working: |
| 151 | + |
| 152 | +```bash |
| 153 | +# Create a test change |
| 154 | +openspec new change test-language |
| 155 | +
|
| 156 | +# Check the instructions - should show your language context |
| 157 | +openspec instructions proposal --change test-language |
| 158 | +
|
| 159 | +# Output will include: |
| 160 | +# <context> |
| 161 | +# Language: Portuguese (pt-BR) |
| 162 | +# All artifacts must be written in Brazilian Portuguese. |
| 163 | +# ... |
| 164 | +# </context> |
| 165 | +``` |
| 166 | + |
| 167 | +## Limitations |
| 168 | + |
| 169 | +- Language instructions apply to **all** artifacts. You cannot set different languages for different artifact types. |
| 170 | +- The effectiveness depends on the AI model's proficiency in the target language. |
| 171 | +- Technical diagrams, code samples, and file paths typically remain in English regardless of language setting. |
| 172 | + |
| 173 | +## Future Considerations |
| 174 | + |
| 175 | +We're considering adding a dedicated `language` field to the config schema in a future release: |
| 176 | + |
| 177 | +```yaml |
| 178 | +# Potential future syntax (not yet implemented) |
| 179 | +schema: spec-driven |
| 180 | +language: pt-BR |
| 181 | +``` |
| 182 | + |
| 183 | +For now, the `context` approach described above is the recommended method. It provides full flexibility and works with all current versions of OpenSpec. |
| 184 | + |
| 185 | +## Related Documentation |
| 186 | + |
| 187 | +- [Project Config Demo](./project-config-demo.md) - Overview of project configuration |
| 188 | +- [Experimental Workflow Guide](./experimental-workflow.md) - Full workflow documentation |
0 commit comments