Skip to content

[FEATURE]: i18n / Locale support (Portuguese and other languages) #35831

Closed as not planned

Description

@RicSchonfelder
  • I have searched existing issues and confirmed this is not a duplicate

Summary

I have since discovered that OpenCode already has an i18n system in place — there are English translation files at packages/ui/src/i18n/en.ts and packages/app/src/i18n/en.ts, and Portuguese is already listed as a language option ("language.br": "Português (Brasil)").

Updated Request: Portuguese (Brazil) translation

Since the infrastructure is already ready, what's needed is the actual Portuguese translation files:

  1. packages/ui/src/i18n/br.ts — translate all UI strings to Portuguese (Brazil)
  2. packages/app/src/i18n/br.ts — translate all app strings to Portuguese (Brazil)

Related previous issues:

Next steps

I understand the process is: community provides the translation → maintainers review and merge.

I'm willing to contribute the Portuguese translation if the maintainers are open to accepting it.

Would that be acceptable?

Activity

  1. github-actions commented on Jul 8, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • Feature requests must have a title starting with [FEATURE]: (current title: "Feature Request: i18n / Locale support (Portuguese and other languages)")
    • Feature requests require a verification checkbox confirming you searched existing issues before submitting

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


    This issue might be a duplicate of existing issues. Please check:

    If you believe this was flagged incorrectly, please let a maintainer know.

  2. changed the title [-]Feature Request: i18n / Locale support (Portuguese and other languages)[/-] [+][FEATURE]: i18n / Locale support (Portuguese and other languages)[/+] on Jul 8, 2026
  3. github-actions commented on Jul 8, 2026

    @github-actions
    Contributor

    Thanks for updating the issue! It now meets our contributing guidelines. We appreciate you adding the [FEATURE]: prefix and the duplicate-search confirmation.

  4. RicSchonfelder commented on Jul 8, 2026

    @RicSchonfelder
    Author

    PR with the complete Portuguese translation has been submitted: #35836

  5. mike652638 commented on Jul 18, 2026

    @mike652638

    Hey @RicSchonfelder — 关于 i18n 支持,我们已经基于官方 Plugin API 实现了中文本地化方案,可供参考和扩展:

    opencode-zh-plugin — 通过 experimental.chat.system.transform hook 注入多语言 system prompt,AI 回复切换为目标语言;同时通过 api.slots.register() 汉化 TUI 界面。理论上只需修改 locale 配置即可扩展到其他语言。

    opencode-zh-desktop — CDP 注入 Desktop Electron UI 的菜单栏翻译。

    如果你计划扩展葡萄牙语或其他语言的支持,插件的 locale/strings.ts 结构和 Plugin API 模式可以直接复用。欢迎参考或 contribute!

    TUI 首页

    AI 中文推理

  6. github-actions commented on Sep 18, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

  7. RicSchonfelder commented on Sep 19, 2026

    @RicSchonfelder
    Author

    @mike652638 obrigado pela sugestão e pelos links! Analisei seu opencode-zh-plugin — abordagem inteligente usando experimental.chat.system.transform e api.slots.register().

    Acabei seguindo um caminho um pouco diferente: como a TUI do OpenCode tem todas as strings hardcoded em inglês (sem camada i18n), fiz um fork com a tradução completa embutida no código-fonte:

    📦 Fork: RicSchonfelder/opencode-i18n-pt (branch feat/pt-br-tui)

    • Paleta de comandos (Ctrl+P) — todos os títulos, categorias e descrições em pt-BR
    • Tela inicial (placeholders, dicas)
    • Comandos de sessão e prompt
    • ~180 descrições de atalhos de teclado
    • Diálogos (agente, provedor, sessões, skills, etc.)
    • Descrições dos agentes nativos

    A diferença da sua abordagem: a sua traduz via plugin (em runtime, sem tocar no repo), a minha traduz o TUI diretamente no código — resultado idêntico para o usuário final, mas sem depender de hooks experimentais. A estrutura locale/strings.ts do seu plugin pode ser útil se alguém quiser um dia portar isso para o mecanismo de plugin oficial.

    Valeu pelo trabalho com o plugin! Qualquer contribuição para o fork é bem-vinda.

  8. RicSchonfelder commented on Sep 19, 2026

    @RicSchonfelder
    Author

    Status: tradução completa disponível no fork 🇧🇷

    Como a TUI do OpenCode não tem camada i18n (todas as strings são hardcoded em inglês), criei o fork RicSchonfelder/opencode-i18n-pt com a tradução embutida:

    Branch feat/pt-br-tui — tradução da interface de terminal:

    • ✅ Paleta de comandos (Ctrl+P) — todos os comandos e categorias em pt-BR
    • ✅ Tela inicial (placeholders, ~120 dicas)
    • ✅ Comandos de sessão e prompt
    • ✅ ~180 descrições de atalhos de teclado
    • ✅ Diálogos (agente, provedor, sessões, skills, stash, renomear, MCP)
    • ✅ Descrições dos agentes nativos

    Base atualizada: a branch dev do fork está sincronizada com o upstream.

    Documentação completa de como a tradução foi feita: TRADUCAO-PT-BR.md

    Se algum mantenedor quiser integrar isso ao upstream, é só dar um git cherry-pick da branch — as mudanças são isoladas em packages/tui/src + descrições de agentes.

  9. RicSchonfelder commented on Sep 19, 2026

    @RicSchonfelder
    Author

    Atualização: build funcional e descoberta importante sobre cross-compile ✅

    O binário Windows traduzido agora funciona de ponta a ponta (incluindo envio de prompts). Uma descoberta relevante para o upstream:

    ⚠️ bun run build no Windows gera binário com bug

    Ao buildar o packages/opencode nativamente no Windows, o binário resultante falha ao enviar qualquer prompt com:

    TypeError: undefined is not an object (evaluating 'a.name')
    

    no LayerNode.walk (packages/core/src/effect/layer-node.ts) — ocorre ao montar o grafo locationServices no SystemPrompt.environment.

    Testei: bun 1.4.2 e 1.3.14, com/sem --minify, com/sem web UI embed, config isolada — todo build no Windows falha.

    ✅ Cross-compile no Linux resolve

    Buildar o mesmo código no Linux (WSL/Ubuntu 24.04, como o GitHub Actions faz) gera um binário Windows funcional:

    wsl
    cd packages/opencode
    bun run build   # builda todos os targets, inclui opencode-windows-x64

    Teste validado: opencode.exe run "diga OK" responde corretamente (exit 0).

    O release oficial sempre foi cross-compilado no Linux — este teste confirma que essa não é só uma escolha de CI, é necessário para um binário Windows correto.

    Fork: RicSchonfelder/opencode-i18n-pt (branch feat/pt-br-stable, base v1.18.25).

  10. RicSchonfelder commented on Sep 20, 2026

    @RicSchonfelder
    Author

    @mike652638 谢谢你的建议和分享你的中文插件!

    我们已经完成了葡萄牙语(巴西)的完整翻译,并解决了你提到的问题:

    ✅ 已完成的工作

    1. 完整的 PT-BR 翻译

    • ~523 字符串翻译在 20 个 TUI 文件中
    • 覆盖:Ctrl+P 命令面板、首页、会话/提示命令、键位描述、工具提示、内置 agents(build/plan/general/explore)的描述

    2. 关键问题修复:Windows build bug

    发现:在 Windows 上原生 build (bun run build) 会生成有 bug 的二进制文件,发送 prompt 时崩溃:

    TypeError: undefined is not an object (evaluating 'a.name')
    

    位置:packages/core/src/effect/layer-node.ts 的 LayerNode.walk 方法

    根因:Windows 原生 build 的 minification/tree-shaking 导致 LayerNode.walk 中的 node.dependencies 包含 undefined,导致 replacementMap.get(node.name) 失败。

    解决方案:必须在 Linux/WSL 上 cross-compile(和 GitHub Actions CI 完全一致):

    wsl
    cd packages/opencode
    bun run build  # 生成所有 targets,包含 Windows x64 baseline

    现在的 release pt-br-v1.18.31 正是用这种方式 build 的,已验证可用。

    3. 版本号修复

    Script.version 在 feature branch 生成 0.0.0-...,导致 Zen 报错 "OpenCode 1.18.0 or newer"。
    修复:build 时指定 OPENCODE_VERSION=1.18.31,现在二进制正确报告 1.18.31。

    4. 仓库结构

    • Fork: RicSchonfelder/opencode-i18n-pt
    • Branch: feat/pt-br-stable (base v1.18.31 + 翻译)
    • Release: pt-br-v1.18.31 包含 baseline + Windows x64

    5. 你的插件启发

    你的 opencode-zh-plugin 用 experimental.chat.system.transform hook 注入 system prompt 的方式很聪明!我们的翻译是直接修改源码字符串,不同路径但目标相同。你的 plugin 结构 (locale/strings.ts) 可以作为未来官方 i18n 支持的参考。


    相关链接

    欢迎 PR 或 issue 讨论!

  11. RicSchonfelder commented on Sep 20, 2026

    @RicSchonfelder
    Author

    @mike652638 谢谢你的建议和分享你的中文插件!

    我们已经完成了葡萄牙语(巴西)的完整翻译,并解决了你提到的问题:

    ✅ 已完成的工作

    1. 完整的 PT-BR 翻译

    • ~523 字符串翻译在 20 个 TUI 文件中
    • 覆盖:Ctrl+P 命令面板、首页、会话/提示命令、键位描述、工具提示、内置 agents(build/plan/general/explore)的描述

    2. 关键问题修复:Windows build bug

    发现:在 Windows 上原生 build (bun run build) 会生成有 bug 的二进制文件,发送 prompt 时崩溃:

    TypeError: undefined is not an object (evaluating 'a.name')
    

    位置:packages/core/src/effect/layer-node.ts 的 LayerNode.walk 方法

    根因:Windows 原生 build 的 minification/tree-shaking 导致 LayerNode.walk 中的 node.dependencies 包含 undefined,导致 replacementMap.get(node.name) 失败。

    解决方案:必须在 Linux/WSL 上 cross-compile(和 GitHub Actions CI 完全一致):

    wsl
    cd packages/opencode
    bun run build  # 生成所有 targets,包含 Windows x64 baseline

    现在的 release pt-br-v1.18.31 正是用这种方式 build 的,已验证可用。

    3. 版本号修复

    Script.version 在 feature branch 生成 0.0.0-...,导致 Zen 报错 "OpenCode 1.18.0 or newer"。
    修复:build 时指定 OPENCODE_VERSION=1.18.31,现在二进制正确报告 1.18.31。

    4. 仓库结构

    • Fork: RicSchonfelder/opencode-i18n-pt
    • Branch: feat/pt-br-stable (base v1.18.31 + 翻译)
    • Release: pt-br-v1.18.31 包含 baseline + Windows x64

    5. 你的插件启发

    你的 opencode-zh-plugin 用 experimental.chat.system.transform hook 注入 system prompt 的方式很聪明!我们的翻译是直接修改源码字符串,不同路径但目标相同。你的 plugin 结构 (locale/strings.ts) 可以作为未来官方 i18n 支持的参考。


    相关链接

    欢迎 PR 或 issue 讨论!

  12. RicSchonfelder commented on Sep 20, 2026

    @RicSchonfelder
    Author

    @mike652638 谢谢你的建议和分享你的中文插件!

    我们已经完成了葡萄牙语(巴西)的完整翻译,并解决了你提到的问题:

    ✅ 已完成的工作

    1. 完整的 PT-BR 翻译

    • ~523 字符串翻译在 20 个 TUI 文件中
    • 覆盖:Ctrl+P 命令面板、首页、会话/提示命令、键位描述、工具提示、内置 agents(build/plan/general/explore)的描述

    2. 关键问题修复:Windows build bug

    发现:在 Windows 上原生 build (bun run build) 会生成有 bug 的二进制文件,发送 prompt 时崩溃:

    TypeError: undefined is not an object (evaluating 'a.name')
    

    位置:packages/core/src/effect/layer-node.ts 的 LayerNode.walk 方法

    根因:Windows 原生 build 的 minification/tree-shaking 导致 LayerNode.walk 中的 node.dependencies 包含 undefined,导致 replacementMap.get(node.name) 失败。

    解决方案:必须在 Linux/WSL 上 cross-compile(和 GitHub Actions CI 完全一致):

    wsl
    cd packages/opencode
    bun run build  # 生成所有 targets,包含 Windows x64 baseline

    现在的 release pt-br-v1.18.31 正是用这种方式 build 的,已验证可用。

    3. 版本号修复

    Script.version 在 feature branch 生成 0.0.0-...,导致 Zen 报错 "OpenCode 1.18.0 or newer"。
    修复:build 时指定 OPENCODE_VERSION=1.18.31,现在二进制正确报告 1.18.31。

    4. 仓库结构

    • Fork: RicSchonfelder/opencode-i18n-pt
    • Branch: feat/pt-br-stable (base v1.18.31 + 翻译)
    • Release: pt-br-v1.18.31 包含 baseline + Windows x64

    5. 你的插件启发

    你的 opencode-zh-plugin 用 experimental.chat.system.transform hook 注入 system prompt 的方式很聪明!我们的翻译是直接修改源码字符串,不同路径但目标相同。你的 plugin 结构 (locale/strings.ts) 可以作为未来官方 i18n 支持的参考。


    相关链接

    欢迎 PR 或 issue 讨论!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions