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

pi-extensions-i18n

v0.4.0

Published

Shared i18n catalog loader & translator for pi extensions

Readme

pi-extensions-i18n

Pi 扩展公共国际化运行时。它提供基于 catalog 的小型 API,支持 zh-CNen-US 和自动语言选择。

为什么需要公共包

独立的 Pi 扩展仍然需要相同的基础能力:可移植的配置路径、语言优先级、fallback、catalog 校验和参数插值。把这些能力集中在这里,功能包就可以专注于自身逻辑,同时保持用户可见文案的一致性。

能力

  • 支持 zh-CNen-USauto 语言偏好。
  • 将设置持久化到 ~/.pi/agent/extensions/pi-extensions-i18n/config.json
  • 支持 PI_EXTENSIONS_LOCALE 环境变量覆盖。
  • 提供 /config:language 交互式命令,也支持 /config:language en-US 直接设置。
  • 加载并校验 catalog,要求每个消息 key 同时提供两种语言。
  • 为 UI、命令描述和 Agent prompt 提供用户文案插值。

安装

pi install npm:pi-extensions-i18n

各功能包会自动安装并加载这个公共依赖,因此安装任意使用它的功能包即可使用语言命令。只有不安装其他功能包、想单独使用语言命令时,才需要直接安装本包。

安装后重新加载 Pi:

/reload

语言优先级

PI_EXTENSIONS_LOCALE 环境变量
    > 持久化配置
    > 默认 zh-CN

选择 auto 时会检查 LC_ALLLC_MESSAGESLANG:中文系统语言解析为 zh-CN,其他语言解析为 en-US。同时接受 zhen 简写。

示例:

PI_EXTENSIONS_LOCALE=en-US pi
/config:language en-US

扩展作者 API

本包导出功能扩展使用的语言和 catalog 原语:

import {
  createTranslator,
  getLocale,
  loadCatalog,
} from "pi-extensions-i18n";

const messages = loadCatalog(new URL("../locales/messages.json", import.meta.url));
const i18n = createTranslator(messages);

i18n.t("description");
getLocale();

catalog 条目必须同时包含两种语言:

{
  "description": {
    "zh-CN": "扩展描述",
    "en-US": "Extension description"
  }
}

无效 catalog 会在加载阶段失败,让缺失翻译在测试和 CI 中暴露,而不是静默向用户泄露单一语言文案。

要求

  • Node.js 22 或更高版本。
  • 使用 /config:language 命令时需要 Pi 扩展运行时;/pi-language 仍作为兼容别名保留。

许可证

MIT