npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

opencode-i18n-v2

v0.3.1

Published

OpenCode V2 i18n plugin — localize the OpenCode 2 interface into 简体中文 / 繁體中文 and more.

Downloads

878

Readme

OpenCode i18n(V2 版)

OpenCode 2 界面本地化插件。把 OpenCode 界面(命令面板标题、描述、斜杠命令说明)本地化为 简体中文 / 繁體中文 等语言。

支持语言:

  • English:原始英文,不改标题和描述
  • 简体中文(zh-Hans)
  • 繁體中文(zh-Hant)

其他语言可自行添加:按同样格式编写语言包(如 ja.json)放到 ~/.config/opencode/i18n/locales/,重启后自动出现在语言列表中。

安装后运行 /i18n,用选项切换语言。选择中文会自动开启本地化;选择 English 会回到原始英文。

本包是 OpenCode V2 专用版本(opencode-i18n-v2)。OpenCode 1.x 请用 opencode-i18n

安装

在 OpenCode 中:

  1. Ctrl + P 打开命令面板
  2. 搜索 install plugin
  3. 输入 opencode-i18n-v2,回车

安装会自动写入 opencode.json(server 端)和 cli.json(TUI 端)的插件列表。重启 OpenCode,运行 /i18n 选择语言。

也可以命令行安装:

opencode2 plugin add opencode-i18n-v2

说明:

  • 插件已发布到 npm,可直接从命令面板安装。
  • 插件自带默认语言包(i18n/locales/*.json),开箱即用。
  • 如需自定义语言包,把文件放到 ~/.config/opencode/i18n/locales/ 即可覆盖默认值。

使用

/i18n

打开语言选择对话框。选择语言即切换。

开关和语言也可通过 i18n-state 工具管理(AI 可直接调用,支持 statussettogglelocalelocales)。

切换语言即时生效(影子命令带内部标记,始终以宿主原始英文标题为翻译来源,无跨语言残留),无需重启。

文件说明

  • src/index.ts:server 插件(Plugin.define),向 OpenCode 注册 i18n-state 工具。
  • src/tui.tsx:V2 TUI 插件入口(Plugin.define({ id, setup })),通过高优先级 keymap layer 注入与宿主命令同 ID 的"影子命令"改写标题/描述/分组名,影子 run: () => false 继续传递执行;注册 /i18n 语言选择命令与导出命令清单命令。影子命令带标记并从来源列表剔除,跨语言切换无残留。
  • i18n/lib.ts:共享路径、状态读取和语言解析逻辑。配置优先读用户目录 ~/.config/opencode/i18n/,缺失时回退到包内默认数据。
  • i18n/config.json:默认语言和内置语言排序。
  • i18n/locales/*.json:独立语言包。新增语言时只要添加一个 locale JSON 即可被自动识别。

语言包格式

按稳定的命令 id 建键(TUI 改文案不会再失配),同一命令的多个动态标题分别翻译:

{
  "name": "简体中文",
  "language_picker": { "question": "...", "option_descriptions": { "en": "..." } },
  "commands": {
    "session.sidebar.toggle": {
      "titles": { "Hide sidebar": "隐藏侧边栏", "Show sidebar": "显示侧边栏" },
      "description": "切换侧边栏显示"
    }
  },
  "groups": { "Agent": "智能体" },
  "slash_commands": { "/share": "分享当前会话" }
}

语言包维护工具

tools/extract-commands.ts:直接读 OpenCode 源码(anomalyco/opencodebeta 分支)提取全量命令清单, 合并运行时 dump 的动态标题变体,与语言包 diff 出缺失 id / 缺失变体 / 多余条目:

bun tools/extract-commands.ts --src <opencode-beta 源码路径>
bun tools/extract-commands.ts --src <path> --skeleton zh-Hans   # 往语言包插空占位
```{N}
分工:源码求全(所有内置 id 和静态标题,固定 commit 与版本对应),dump 补动态标题变体。
升级 OpenCode 后跑一次即可,不再需要逐一打开界面积攒命令。

TUI 运行中也会自动把当前命令清单防抖写入 `~/.config/opencode/i18n/commands-dump.json`
(命令面板可手动执行 **Export i18n command list**),作为源码提取之外的变体补充。

## 从 V1(opencode-i18n)迁移

V2 版与 V1 共享同一份状态文件(`~/.local/state/opencode/i18n-state.json`)和语言包目录,**已选的语言和开关状态会保留**,无需重新设置。

## 与 V1 的差异

- 包名 `opencode-i18n-v2`,面向 OpenCode 2(`@opencode-ai/plugin@beta`)。
- TUI 入口使用 V2 的 `setup(context)`,通过 keymap layer 接入命令目录和斜杠命令。
- server 工具改用 V2 的 `ctx.tool.transform` 注册,输入用 `effect` Schema 声明。