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

@koishi-ce/i18n-utils

v1.0.1

Published

I18n Utilities for Koishi

Readme

@koishi-ce/i18n-utils

简体中文 | English

Koishi 的国际化辅助库,移植自上游 koishijs/koishi 的 packages/i18n-utils。它解决两个问题:把一组语言环境名构建为嵌套树,以及依据用户偏好计算回退查找顺序——核心包 I18n 服务的回退机制即建立在其上。

主要导出

  • LocaleTree:LocaleTree.from(locales) 把 zh-CN / zh-TW / en-US 等语言环境名按 - 逐级展开为嵌套树;实现使用 null 原型对象防止原型污染。
  • fallback(tree, locales):依据用户偏好语言列表计算回退查找顺序——精确环境优先,依次退到各级父语言、根,再到其余可用语言;多个偏好按序处理并上移命中节点以保证优先级。

函数签名与 @intlify/core-base 保持兼容(Vue I18n 的底层库),便于类型互认。

用法

import { LocaleTree, fallback } from "@koishi-ce/i18n-utils";

const tree = LocaleTree.from(["zh-CN", "zh-TW", "en-US"]);
fallback(tree, ["zh-TW", "en-US"]); // => ["zh-TW", "en-US", "zh", "zh-CN", "en", ""]

普通用户无需安装本包,它由 @koishi-ce/core 引入。

许可证

MIT。本包是上游 koishijs/koishi 的社区再分发,版权归属见 NOTICE。


English

I18n utilities for Koishi, ported from packages/i18n-utils of the upstream koishijs/koishi. It does two things: builds a nested tree from a set of locale names, and computes fallback lookup orders from user preferences — the foundation of the I18n service in @koishi-ce/core.

Key exports

  • LocaleTree — LocaleTree.from(locales) expands locale names such as zh-CN / zh-TW / en-US into a nested tree by splitting on -, using null-prototype objects to guard against prototype pollution.
  • fallback(tree, locales) — computes the fallback lookup order for a list of preferred locales: exact locale first, then each parent language up to the root, then remaining available languages.

The function signatures intentionally stay compatible with @intlify/core-base (the core of Vue I18n).

Usage

import { LocaleTree, fallback } from "@koishi-ce/i18n-utils";

const tree = LocaleTree.from(["zh-CN", "zh-TW", "en-US"]);
fallback(tree, ["zh-TW", "en-US"]); // => ["zh-TW", "en-US", "zh", "zh-CN", "en", ""]

End users never install this package directly; it is a dependency of @koishi-ce/core.

License

MIT. Community redistribution of upstream koishijs/koishi; see NOTICE for attribution.