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

kiro-i18n

v1.0.0

Published

Lightweight, type-safe internationalization library with property-based testing

Downloads

89

Readme

@kiro/i18n

npm version License: MIT TypeScript

Lightweight, type-safe internationalization (i18n) library with comprehensive property-based testing. Built for modern TypeScript applications with a focus on reliability and developer experience.

✨ Features

  • 🌍 Multi-language Support: Built-in support for English, Simplified Chinese, and Traditional Chinese
  • 📦 Modular Architecture: Organized translation files by feature (menu, settings, commands, etc.)
  • 🔒 Type-Safe: Full TypeScript support with comprehensive type definitions
  • 🚀 Performance Optimized: In-memory caching and lazy loading
  • 🎯 Text Interpolation: Dynamic content with {{variable}} syntax
  • 🔄 Graceful Fallback: Automatic fallback to default language when translations are missing
  • 💾 Persistent Preferences: Save and restore user language preferences
  • 🧪 Property-Based Testing: Comprehensive test coverage using fast-check
  • 📝 BCP 47 Compliant: Standard language codes (e.g., "zh-CN", "en-US")

📦 Installation

npm install @kiro/i18n

🚀 Quick Start

import { getI18nAPI } from '@kiro/i18n';

// Initialize the i18n system
const i18n = getI18nAPI({
  localesPath: './locales',
  defaultLanguage: 'en-US',
  fallbackLanguage: 'en-US'
});

await i18n.initialize();

// Translate a key
const greeting = i18n.t('common.hello'); // "Hello"

// Translate with interpolation
const welcome = i18n.t('common.welcome', { name: 'Alice' }); // "Welcome Alice"

// Change language
await i18n.changeLanguage('zh-CN');
const greetingCN = i18n.t('common.hello'); // "你好"

// Listen to language changes
i18n.onLanguageChange((newLanguage) => {
  console.log(`Language changed to: ${newLanguage}`);
});

📁 Project Structure

your-project/
├── locales/
│   ├── languages.json            # Language metadata
│   ├── en-US/                    # English translations
│   │   ├── common.json
│   │   ├── menu.json
│   │   └── settings.json
│   └── zh-CN/                    # Simplified Chinese translations
│       ├── common.json
│       ├── menu.json
│       └── settings.json
└── src/
    └── index.ts

📝 Translation File Format

Translation files use nested JSON structure:

{
  "menu": {
    "file": {
      "label": "文件",
      "open": "打开",
      "save": "保存"
    }
  },
  "common": {
    "welcome": "欢迎 {{name}}"
  }
}

Access translations using dot-separated keys: menu.file.open

🔧 API Reference

getI18nAPI(config?: I18nConfig): I18nAPI

Get the singleton instance of the i18n API.

Config Options:

  • localesPath: Path to translation files (default: 'locales')
  • defaultLanguage: Default language code (default: 'en-US')
  • fallbackLanguage: Fallback language code (default: 'en-US')

I18nAPI Methods

initialize(): Promise<void>

Initialize the i18n system and load the default language.

t(key: string, params?: Record<string, string>): string

Translate a key with optional parameter interpolation.

changeLanguage(languageCode: LanguageCode): Promise<void>

Change the current language.

getCurrentLanguage(): LanguageCode

Get the current language code.

getSupportedLanguages(): LanguageInfo[]

Get list of all supported languages.

onLanguageChange(callback: (language: LanguageCode) => void): () => void

Register a callback for language changes. Returns an unsubscribe function.

🧪 Testing

The library includes comprehensive test coverage with both unit tests and property-based tests:

# Run all tests
npm test

# Run tests in watch mode
npm run test:watch

# Run tests with UI
npm run test:ui

# Generate coverage report
npm run test:coverage

🏗️ Building

# Build for production
npm run build

# Build and watch for changes
npm run dev

# Type check
npm run lint

📄 Language Metadata

Define supported languages in locales/languages.json:

{
  "languages": [
    {
      "code": "en-US",
      "name": "English",
      "nativeName": "English"
    },
    {
      "code": "zh-CN",
      "name": "Simplified Chinese",
      "nativeName": "简体中文"
    }
  ]
}

🎯 Use Cases

  • Desktop applications (Electron, Tauri)
  • Web applications (React, Vue, Angular)
  • CLI tools
  • VS Code extensions
  • Any TypeScript/JavaScript project requiring i18n

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📜 License

MIT © Kiro Team

🔗 Links

🙏 Acknowledgments

Built with: