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

@askrjs/i18n

v0.4.0

Published

Application-owned, typed internationalization scopes for Askr.

Readme

@askrjs/i18n

CI npm version

Typed, application-owned internationalization for Askr. The package does not choose locales, parse ICU messages, or install process-global state.

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

const i18n = createI18n("en", {
  en: {
    welcome: ({ name }: { name: string }) => `Welcome, ${name}`,
    total: (value: number) =>
      new Intl.NumberFormat("en-US", { style: "currency", currency: "USD" }).format(value),
  },
  fr: {
    welcome: ({ name }: { name: string }) => `Bienvenue, ${name}`,
    total: (value: number) =>
      new Intl.NumberFormat("fr-FR", { style: "currency", currency: "EUR" }).format(value),
  },
});

function Welcome() {
  return <h1>{i18n.text("welcome", { name: "Ada" })}</h1>;
}

function LocalizedMain() {
  return (
    <main {...i18n.attributes()}>
      <Welcome />
    </main>
  );
}

<i18n.Scope locale="fr">
  <LocalizedMain />
</i18n.Scope>;

Language and direction

Locale state and HTML direction must change together. For the initial server render, apply the same frozen attributes to the document element:

import { applyLocaleAttributes, localeAttributes } from "@askrjs/i18n";

const attributes = localeAttributes(locale);
// Server template: <html lang={attributes.lang} dir={attributes.dir}>

// Client boot and later locale switches use the same resolved attributes.
applyLocaleAttributes(document.documentElement, attributes);

localeAttributes() uses Intl.Locale#getTextInfo() where available and a deterministic compatibility fallback. Pass an explicit second argument when an application uses a non-default script policy that needs an override:

const attributes = localeAttributes("az-Arab", "rtl");

i18n.attributes() reads the active lexical scope. Spread it onto a real DOM element when a nested subtree uses a different language or direction. The package does not insert a wrapper or mutate the global document implicitly.

For user-provided text whose direction is unknown, use semantic HTML isolation:

<p>
  Account: <bdi>{userDisplayName}</bdi>
</p>
<input dir="auto" name="displayName" />

Use CSS logical properties (margin-inline-start, padding-inline, inset-inline-end, text-align: start) for direction-sensitive layout rather than mirrored left/right rules.

Applications own locale resolution from URL prefixes, hosts, cookies, or user profiles. i18n.dehydrate() returns an immutable, versioned snapshot containing the active locale, direction, and selected catalog identity. Pass that snapshot back as <i18n.Scope hydration={snapshot}> during hydration.

The first argument names the source locale. Its exact keys and message argument tuples are required from every other locale; missing, extra, or incompatible messages fail during type checking and are also rejected at runtime.

See the runtime contract for isolation and hydration details.