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

@broberg/i18n

v0.1.0

Published

Headless locale engine: a framework-free createI18n() with dot-path t() (fallback chain + {var} interpolation), a bilingual() helper for {da,en} content objects, localStorage persistence + navigator.language detection, an html[lang] sync, a pub/sub with n

Readme

@broberg/i18n

A headless locale engine — the same ~120-line i18n core that trail, sanneandersen and xrt81 each hand-rolled, extracted once. Detect the locale, persist it, resolve a dot-path key with a fallback chain + {var} interpolation, and a bilingual() helper for {da,en} content objects. Framework-free, SSR-safe, and pnpm-hoist-safe. The LanguageSwitcher widget stays copy-owned per stack.

npm i @broberg/i18n

Usage

import { createI18n } from "@broberg/i18n";

const i18n = createI18n({
  locales: ["da", "en"],                // first = default
  fallbackLocale: "en",                 // the complete base dict
  messages: {
    da: { greeting: "Hej", nav: { home: "Hjem" } },
    en: { greeting: "Hello", nav: { home: "Home" }, welcome: "Hi {name}" },
  },
  storageKey: "acme-locale",
});

i18n.getLocale();                        // "da" (stored > navigator.language > default)
i18n.t("nav.home");                      // "Hjem"
i18n.t("welcome", { name: "Sanne" });    // "Hi Sanne"  (falls back to en, interpolates)
i18n.setLocale("en");                    // persists, syncs <html lang>, notifies subscribers
i18n.bilingual({ da: "Goddag", en: "Good day" });   // active-locale string, plain-string tolerant

const off = i18n.subscribe((locale) => rerender());  // pub/sub, no context provider

What it gets right

  • Fallback chaint(key) resolves the active locale, then the fallback locale, then returns the raw key (never a blank string).
  • {var} interpolationt("welcome", { name }) fills placeholders.
  • bilingual() — picks the active-locale field from a {da,en} object and tolerates a plain string, so LLM-generated bilingual content and legacy plain strings both work.
  • Detection — stored locale → navigator.language prefix-match → default, all SSR-guarded.
  • pnpm-hoist safe — a globalThis-keyed registry means two bundle copies with the same storageKey share one instance, so the active locale can never desync.

API

createI18n({ locales, defaultLocale?, fallbackLocale?, messages?, storageKey?, storage?, detect? }): I18n
// I18n: getLocale · setLocale · subscribe · t(key, vars?) · bilingual(text) · detectInitial · locales

Dictionaries stay in your repo (bundling them into the package would couple every consumer's copy) — the package ships only the engine. React (Next URL-prefix switch) and Preact (pub/sub) LanguageSwitcher adapters build on this core.

License

MIT · part of the @broberg/* shared inventory.