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

@stream-io/i18n

v1.0.2

Published

Translation runtime shared across Stream.io JS SDKs: i18next wrapper, date/time formatters and a build-time catalog generator

Downloads

1,134

Readme

@stream-io/i18n

The translation runtime shared across Stream's JS SDKs — an i18next wrapper, a date/time layer built on dayjs, and a build-time generator that derives a type-only translation catalog from your t() call sites.

Framework-agnostic: nothing in the main entry point knows about Chat, Video or Feeds.

import { Streami18n } from "@stream-io/i18n";

const i18n = new Streami18n({ language: "de" });

i18n.registerTranslation("de", { "common.cancel.label": "Abbrechen" });
await i18n.init();

i18n.t("common.cancel.label"); // "Abbrechen"

Entry points

| Import | Contents | | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | | @stream-io/i18n | Streami18n, formatters, getDateString, the dayjs layer, TranslationStore, TranslationBuilder, catalog-generic type helpers | | @stream-io/i18n/react | useStreami18nState, createTranslationContext | | @stream-io/i18n/codegen | The catalog generator. Node-only, ESM-only, build-time |

react is the only peer dependency, and it is optional — needed just for the /react subpath. i18next, dayjs, @stream-io/state-store and use-sync-external-store are direct dependencies, so nothing extra has to be installed alongside. use-sync-external-store in particular is a dependency rather than a peer because /react imports it unconditionally, to keep the React 17 floor.

No catalog ships with this package

Each SDK generates its own keys.ts from its own t() call sites, so the type helpers are generic over it:

import type { StreamTFunctionFor } from "@stream-io/i18n";
import type { TranslationCatalog, BundledKey } from "./i18n/keys.ts";

type StreamTFunction = StreamTFunctionFor<TranslationCatalog, BundledKey>;

Bundled must default to never. Defaulting it to string collapses the prose overload and silently disables all key checking.

Keys with no possible inline default — formatter expressions such as timestamp.* — are supplied through the runtimeDefaults constructor option rather than imported, because the catalog belongs to the UI layer. They are layered under every language, which is what stops a partial dictionary from knocking out formatter keys.

Reactivity

Streami18n.state is a StateStore, so language changes propagate without listeners:

const unsubscribe = i18n.state.subscribe(({ t, language }) => render(t, language));

subscribe fires synchronously with the current value. In React, use the binding:

import { useStreami18nState } from "@stream-io/i18n/react";

const { t, tDateTimeParser } = useStreami18nState(i18n);

init() is memoized, so several components sharing one instance share one initialization.

Guarantees

Three behaviours are covered by dedicated tests, each written against a real bug (src/__tests__/Streami18nGuarantees.test.ts):

  • G1 — the SDK's bundled defaults are layered under every language, however it was selected.
  • G2 — a partial dictionary is safe: an unsupplied key renders English, never a raw dotted path.
  • G3 — selecting an unregistered language warns and continues; it must not silently reset to en.

Notes

  • No module-scope side effects. Every Dayjs.extend goes through ensureDayjsPlugins(), which is what makes sideEffects: false accurate. Do not reintroduce a top-level extend.
  • durationFormatter takes milliseconds, not a timestamp. Parsing 600000 as a timestamp renders "57 years ago".
  • i18next post-processing is global. A TranslationTopic is invoked for every key and must pass through calls it does not recognize, or it silently rewrites unrelated copy.
  • Intl.PluralRules coverage is warned about, not polyfilled. Hermes ships a partial ICU; React Native consumers should import intl-pluralrules themselves before init().
  • Date assertions are timezone-sensitive — the test script pins TZ=UTC.