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

yamlocale

v0.1.1

Published

YAML to JSON i18n dictionary converter with CLI support

Readme

yamlocale

YAML to JSON i18n dictionary converter with CLI support.

Features

  • 🌐 Convert YAML translation files to JSON format
  • 📦 Smart namespace detection (file-based or directory-based)
  • 🔄 Auto-detection of available languages
  • ✅ Validation for missing translations and duplicate keys
  • 🎯 Support for both flat and nested output formats
  • 👀 Watch mode for automatic regeneration
  • 🚀 Built with Bun, TypeScript, and modern tooling

Installation

npm install yamlocale
# or
bun install yamlocale

Usage

CLI

yamlocale <source-dir> <output-dir> [options]

Options

  • -l, --languages <languages> - Comma-separated list of languages (e.g., ja,en). Auto-detected if not specified.
  • -f, --format <format> - Output format: flat or nested (default: nested)
  • -w, --watch - Watch mode: automatically regenerate on file changes

Examples

# Basic usage with auto-detected languages
yamlocale ./src/i18n ./dist/locales

# Specify languages explicitly
yamlocale ./src/i18n ./dist/locales --languages ja,en,fr

# Use flat output format
yamlocale ./src/i18n ./dist/locales --format flat

# Enable watch mode
yamlocale ./src/i18n ./dist/locales --watch

Programmatic API

import { convert } from "yamlocale";

await convert({
  sourceDir: "./src/i18n",
  outputDir: "./dist/locales",
  languages: ["ja", "en"], // Optional: auto-detected if not specified
  format: "nested", // Optional: "flat" or "nested" (default: "nested")
});

Directory Structure and Namespace Strategy

The output JSON filename (namespace) is automatically determined by the file placement in the source directory.

Rules

  1. Root-level files

    • Filename becomes the namespace
    • Source: ${sourceDir}/home.yaml
    • Output: ${outputDir}/{locale}/home.json
  2. Subdirectory files

    • Directory name becomes the namespace
    • Filename becomes the key prefix
    • Source: ${sourceDir}/common/button.yaml
    • Output: ${outputDir}/{locale}/common.json

YAML Format

  • Language co-location: Include all languages in a single file
  • Completeness: All leaf nodes must have translations for all languages
  • Nesting: Support for arbitrary nesting depth (2-3 levels recommended)

Example

# src/i18n/common/button.yaml
add:
  ja: 追加
  en: Add
delete:
  ja: 削除
  en: Delete

Output Formats

Nested (default)

{
  "button": {
    "add": "Add",
    "delete": "Delete"
  }
}

Flat

{
  "button.add": "Add",
  "button.delete": "Delete"
}

Validation

The converter performs the following validations:

  • Missing translations: Ensures all keys have translations for all target languages
  • Duplicate keys: Detects duplicate keys within the same namespace

Compatibility

Generated JSON files are compatible with popular i18n libraries:

  • i18next
  • react-intl
  • vue-i18n
  • And other standard JSON-based i18n solutions

Development

# Install dependencies
npm install

# Build
npm run build

# Test
npm test

# Format code
npm run format

# Type check
npm run typecheck

License

MIT

Credits

Inspired by colocale by Urotea.