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

@aryagg/i18n

v1.0.1

Published

Shared internationalization utilities for aryagg packages

Readme

@aryagg/i18n

Lightweight internationalization (i18n) utility for aryagg packages. Supports translation lookup, nested keys, variable interpolation, plural forms, and lazy-loaded messages.

npm GitHub


Installation

npm install @aryagg/i18n

Quick Start

import { createI18n } from '@aryagg/i18n';

const i18n = createI18n({
  locale: 'en',
  fallbackLocale: 'en',
  messages: {
    en: {
      greeting: 'Hello, {name}!',
      nav: {
        home: 'Home',
        about: 'About',
      },
    },
    ar: {
      greeting: 'مرحبا، {name}!',
      nav: {
        home: 'الرئيسية',
      },
    },
  },
});

i18n.t('greeting', { name: 'Alice' }); // "Hello, Alice!"
i18n.t('nav.home');                    // "Home"

Core API

createI18n(options)

Creates and returns an I18n instance.

const i18n = createI18n({
  locale: 'en',               // active language
  fallbackLocale: 'en',       // used when a key is missing in the active locale
  messages: { ... },          // translation dictionary
  missing: (key, locale) => { // optional: called when a key is not found
    console.warn(`[i18n] missing "${key}" in "${locale}"`);
  },
});

i18n.t(key, params?)

Looks up a translation key. Supports dot notation for nested keys and {placeholder} interpolation.

i18n.t('nav.home');                        // "Home"
i18n.t('greeting', { name: 'Alice' });     // "Hello, Alice!"
i18n.t('missing.key');                     // returns "missing.key" (key as fallback)

i18n.setLocale(locale) / i18n.getLocale()

Switch the active language at runtime.

i18n.setLocale('ar');
i18n.t('greeting', { name: 'Alice' }); // "مرحبا، Alice!"
i18n.getLocale();                       // "ar"

i18n.addMessages(locale, map)

Merge additional messages into a locale — useful for lazy loading translation files.

i18n.addMessages('fr', {
  greeting: 'Bonjour, {name}!',
});

i18n.setLocale('fr');
i18n.t('greeting', { name: 'Alice' }); // "Bonjour, Alice!"

i18n.getLocales()

Returns all loaded locale codes.

i18n.getLocales(); // ["en", "ar", "fr"]

interpolate(template, params)

Standalone function — replaces {key} placeholders in any string.

import { interpolate } from '@aryagg/i18n';

interpolate('Hello, {name}! You have {count} messages.', { name: 'Alice', count: 3 });
// "Hello, Alice! You have 3 messages."

interpolate('Hi {name}', {});
// "Hi {name}"  ← unknown placeholders are left unchanged

plural(count, forms, params?)

Picks the correct word form based on count.

import { plural } from '@aryagg/i18n';

plural(0, { zero: 'No items',  one: '1 item', other: '{n} items' }, { n: 0 }); // "No items"
plural(1, {                    one: '1 item', other: '{n} items' }, { n: 1 }); // "1 item"
plural(5, {                    one: '1 item', other: '{n} items' }, { n: 5 }); // "5 items"

PluralForms shape:

interface PluralForms {
  one: string;
  other: string;
  zero?: string; // optional — falls back to "other" if not provided
}

TypeScript Types

import type {
  Locale,            // string — e.g. "en", "ar"
  TranslationMap,    // { [key: string]: string | TranslationMap }
  TranslationMessages, // Record<Locale, TranslationMap>
  I18nOptions,       // options for createI18n()
  PluralForms,       // { one, other, zero? }
} from '@aryagg/i18n';

Source

github.com/iron-throne/skeleton-packages/tree/main/packages/i18n