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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@zachhandley/ez-i18n

v0.3.5

Published

Cookie-based i18n for Astro. Core package with Astro integration and runtime.

Downloads

1,659

Readme

@zachhandley/ez-i18n

Cookie-based i18n for Astro. Ships the Astro integration plus the shared runtime stores used by the React/Vue bindings.

Installation

pnpm add @zachhandley/ez-i18n nanostores @nanostores/persistent

Astro Setup

// astro.config.ts
import { defineConfig } from 'astro/config';
import vue from '@astrojs/vue';
import ezI18n from '@zachhandley/ez-i18n';

export default defineConfig({
  integrations: [
    vue(),
    ezI18n({
      locales: ['en', 'es', 'fr'],
      defaultLocale: 'en',
      translations: {
        en: './src/i18n/en.json',
        es: './src/i18n/es.json',
      },
    }),
  ],
});

Add EzI18nHead to your layout to hydrate the locale + translations on the client:

---
import EzI18nHead from '@zachhandley/ez-i18n/astro';
const { locale, translations } = Astro.locals;
---

<html lang={locale}>
  <head>
    <EzI18nHead locale={locale} translations={translations} />
  </head>
  <body><slot /></body>
</html>

Translations

Place JSON files per locale (auto-discovered in public/i18n/ by default):

{
  "common": {
    "welcome": "Welcome",
    "save": "Save",
    "cancel": "Cancel"
  },
  "auth": {
    "login": "Log in",
    "signup": "Sign up"
  }
}

Use dot notation and {placeholder} interpolation:

import { t, locale, setLocale } from 'ez-i18n:runtime';

t('common.welcome'); // "Welcome"
t('auth.signup'); // "Sign up"
t('common.countdown', { seconds: 5 }); // "Ready in 5 seconds"
await setLocale('es');

Virtual Modules

ez-i18n:runtime

Core translation functions:

import { t, locale, setLocale, initLocale } from 'ez-i18n:runtime';

t('key');                    // Translate a key
t('key', { name: 'World' }); // With interpolation
locale;                      // Reactive store with current locale
await setLocale('es');       // Change locale (persists to cookie)
initLocale('en', data);      // Initialize with translations

ez-i18n:config

Access your i18n configuration:

import {
  locales,          // ['en', 'es', 'fr']
  defaultLocale,    // 'en'
  cookieName,       // 'ez-locale'
  localeNames,      // { en: 'English', es: 'Español', fr: 'Français' }
  localeToBCP47,    // { en: 'en-US', es: 'es-ES', fr: 'fr-FR' }
  localeDirections, // { en: 'ltr', es: 'ltr', ar: 'rtl' }
} from 'ez-i18n:config';

ez-i18n:translations

Dynamic translation loading:

import { loadTranslations, translationLoaders } from 'ez-i18n:translations';

const data = await loadTranslations('es');

Locale Utilities

The package includes a comprehensive locale database with 100+ languages:

import {
  LOCALE_DATABASE,
  getLocaleInfo,
  buildLocaleNames,
  buildLocaleToBCP47,
  buildLocaleDirections,
} from '@zachhandley/ez-i18n';
import type { LocaleInfo } from '@zachhandley/ez-i18n';

// Get info for any locale
const info = getLocaleInfo('es');
// { name: 'Español', englishName: 'Spanish', bcp47: 'es-ES', dir: 'ltr' }

// Build mappings for your supported locales
const names = buildLocaleNames(['en', 'es', 'ar']);
// { en: 'English', es: 'Español', ar: 'العربية' }

const directions = buildLocaleDirections(['en', 'es', 'ar']);
// { en: 'ltr', es: 'ltr', ar: 'rtl' }

Includes native display names, English names, BCP47 codes, and text direction (LTR/RTL) for all major languages and regional variants.

Framework Bindings

  • React: @zachhandley/ez-i18n-react
  • Vue 3: @zachhandley/ez-i18n-vue

Both reuse the runtime stores provided by this package.

License

MIT