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

@godgpt/i18n

v0.1.1

Published

Internationalization module for GodGPT SDK with lazy loading

Readme

@godgpt/i18n

Internationalization (i18n) module for the GodGPT SDK with interpolation and pluralization.

Installation

npm install @godgpt/core @godgpt/i18n
# or
pnpm add @godgpt/core @godgpt/i18n
# or
yarn add @godgpt/core @godgpt/i18n

Usage

Basic Setup

import { createSDK } from "@godgpt/core";
import { I18nModule } from "@godgpt/i18n";

const sdk = createSDK();
const i18n = sdk.use(
  new I18nModule({
    defaultLocale: "en",
    supportedLocales: ["en", "es", "zh-CN"],
    fallbackLocale: "en",
    loadResources: async (locale) => {
      // Load translations from API, file, etc.
      const response = await fetch(`/locales/${locale}.json`);
      return response.json();
    },
  })
);

await sdk.init();

Translation Files

// en.json
{
  "hello": "Hello",
  "greeting": "Hello, {{name}}!",
  "items_zero": "No items",
  "items_one": "1 item",
  "items_other": "{{count}} items"
}

Basic Translation

// Simple translation
i18n.t("hello"); // "Hello"

// With interpolation
i18n.t("greeting", { name: "World" }); // "Hello, World!"

// With default value
i18n.t("missing.key", { defaultValue: "Fallback" }); // "Fallback"

Pluralization

i18n.t("items", { count: 0 }); // "No items"
i18n.t("items", { count: 1 }); // "1 item"
i18n.t("items", { count: 5 }); // "5 items"

Changing Locale

// Get current locale
console.log(i18n.getLocale()); // "en"

// Change locale
await i18n.setLocale("es");

// Check supported locales
console.log(i18n.getSupportedLocales()); // ["en", "es", "zh-CN"]
console.log(i18n.isSupported("fr")); // false

Preloading Locales

// Preload translations for faster switching
await i18n.preload("es");
await i18n.preload("zh-CN");

// Check if loaded
console.log(i18n.isLoaded("es")); // true

Adding Translations at Runtime

i18n.addResources("en", {
  "new.key": "New translation",
  "another.key": "Another one",
});

i18n Events

sdk.on("i18n:ready", () => {
  console.log("i18n is ready");
});

sdk.on("i18n:localeChanged", ({ locale, previousLocale }) => {
  console.log(`Locale changed from ${previousLocale} to ${locale}`);
});

API Reference

I18nModule Constructor Options

  • defaultLocale (string): Initial locale
  • supportedLocales (string[]): List of supported locales
  • fallbackLocale (string): Fallback when translation missing
  • loadResources (function): Async function to load translations
  • cacheResources (boolean): Cache loaded translations (default: true)

Methods

  • t(key, options?): Translate a key
  • getLocale(): Get current locale
  • setLocale(locale): Change locale
  • getSupportedLocales(): Get all supported locales
  • isSupported(locale): Check if locale is supported
  • isLoaded(locale): Check if locale translations are loaded
  • preload(locale): Preload translations for a locale
  • addResources(locale, resources): Add translations at runtime
  • exists(key): Check if a translation key exists
  • getResource(key): Get raw translation value

Translation Options

  • defaultValue (string): Fallback if key not found
  • count (number): For pluralization
  • Any other keys for interpolation (e.g., { name: "John" })

License

MIT