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

@zerotal/i18n

v1.7.5

Published

Internationalization and localization for Zerotal applications.

Readme

@zerotal/i18n

Request-scoped internationalization with interpolation, pluralization, and fallback.

Resolves each visitor's locale automatically from the query string, a cookie, or the Accept-Language header, then translates message keys with interpolation, pluralization, and locale fallback. Translations are available on the request context (http.t), through the Lang facade, and via the global t() helper.

Part of the Zerotal framework. Requires Bun ≥ 1.3.14.

Installation

bun add @zerotal/i18n

Setup

Register the provider in bootstrap/providers.ts:

import { I18nProvider } from "@zerotal/i18n";

export default [I18nProvider];

I18nProvider registers LocaleMiddleware, which resolves the locale for every request and injects ctx.t() and ctx.locale. Configure it in config/i18n.ts:

// config/i18n.ts
import { I18nConfig } from "@zerotal/i18n";
import { env } from "@zerotal/core";

export default I18nConfig({
  defaultLocale: env("APP_LOCALE", "en"),
  fallbackLocale: env("APP_FALLBACK_LOCALE", "en"),
  supportedLocales: ["en", "fr", "es"],
  resolvers: ["query", "cookie", "accept-header"], // tried in order
  queryKey: "lang", // ?lang=fr
  cookieKey: "locale", // locale=fr cookie
  loadPath: "resources/lang", // <locale>.json catalogs
});

Usage

Translate from a controller via the request context:

async show({ http }: Context) {
  http.t("welcome.greeting", { name: "Alice" });       // active locale
  http.t("welcome.greeting", { name: "Alice" }, "fr"); // explicit locale
  return http.response.json({ locale: http.locale });
}

Anywhere else, use the Lang facade or the global t() helper — both honour the active request locale via I18nContext:

import { Lang, t } from "@zerotal/i18n";

Lang.translate("auth.login.title");
t("dashboard.welcome");

// Override the resolved locale for the current request:
Lang.setLocale("fr");

Catalogs support nested or flat dotted keys, {name}/:name interpolation, and pipe-separated pluralization chosen by count:

{
  "welcome": { "greeting": "Hello, {name}!" },
  "validation.required": "The :field field is required.",
  "apples": "no apples | one apple | {count} apples"
}
t("apples", { count: 0 }); // "no apples"
t("apples", { count: 5 }); // "5 apples"

A key missing in the active locale falls back to fallbackLocale; if still missing, the key itself is returned (gaps are visible, never thrown).

Exports

  • Translator — the core translation service (and TranslatorOptions).
  • I18nProvider — registers LocaleMiddleware and binds the translator.
  • LocaleMiddleware — resolves the locale per request and injects ctx.t/ctx.locale.
  • I18nContext — async-local storage holding the active request locale.
  • Lang, t — facade and global helper that read the active locale.
  • I18nConfig / I18nConfigShape — config factory and its shape.
  • loadCatalogs — load <locale>.json catalogs from disk.
  • resolveLocale, parseAcceptLanguage — locale resolution helpers.
  • Types: Messages, Catalogs, Replacements, LocaleResolver.
  • Errors: I18nError (E_I18N), CatalogLoadError (E_I18N_CATALOG_LOAD).

Documentation