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

rvlib-i18n

v1.0.0

Published

Type-safe i18n the simple way: the EN dict is the source of truth, every locale typechecks against it (missing keys and wrong interpolation args are compile errors), one mobx-observable singleton holds the persisted locale. No framework, no ICU, no catalo

Readme

rvlib-i18n

Type-safe i18n the simple way. No framework, no ICU syntax, no JSON catalogs, no key-string parsing: TypeScript is the engine, mobx makes the locale switch render.

The idea: your primary dict is the source of truth, and every other locale must typecheck against it. A missing key, an extra key, or a wrong interpolation argument is a compile error, not a runtime surprise.

// src/i18n/en.ts — the source of truth
export const en = {
    ui: { save: "Save" },
    err: { tooShort: ({ min }: { min: number }): string => `Must be at least ${min} characters` },
}

// src/i18n/fr.ts — parity enforced by the compiler
import type { en } from "./en"
export const fr: typeof en = {
    ui: { save: "Enregistrer" },
    err: { tooShort: ({ min }) => `Au moins ${min} caractères` },
}

// src/i18n/index.ts — the app's ONE singleton
import { createI18n } from "rvlib-i18n"
import { en } from "./en"
import { fr } from "./fr"
export const i18n = createI18n({ dicts: { en, fr }, fallback: "en" })

Usage anywhere:

i18n.t.ui.save                    // typed, autocompleted
i18n.t.err.tooShort({ min: 8 })   // interpolation args typechecked
i18n.set("fr")                    // persists to localStorage, observers re-render
i18n.lang                         // current locale, observable
i18n.toggle()                     // cycle locales (a settings row, a debug key)

Every mobx observer component that reads i18n.t.* re-renders on a locale switch. Non-mobx render loops (canvas, pixi) can poll a signature string that includes i18n.lang.

Pluralization, articles, casing, and per-locale formatting live INSIDE the dict as plain typed functions. The function absorbs whatever the language needs, including different plural boundaries per language:

// EN takes the plural at 0, FR keeps the singular noun at 0 and 1
tooFewItems: ({ min }: { min: number }) => `Needs at least ${min === 1 ? "1 item" : `${min} items`}`
tooFewItems: ({ min }) => `Doit contenir au moins ${min < 2 ? `${min} élément` : `${min} éléments`}`

Peer dependency: mobx ^6. localStorage access is try/catch'd, so tests, SSR and private mode degrade to session-only.