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

@saidksi/localizer-core

v0.2.1

Published

Core i18n automation library for localizer

Readme

@saidksi/localizer-core

Core library for the Localizer i18n CLI tool. Provides AST-based string detection, AI-powered i18n key generation, code transformation, and validation.

Features

  • Scanner: AST-based detection of hardcoded strings in TypeScript/JavaScript code
  • AI Integration: Provider-agnostic support for Anthropic and OpenAI APIs
  • Rewriter: Automatic code transformation to replace hardcoded strings with i18n function calls
  • Validator: Key coverage validation across multiple language files
  • Cache: Smart caching to avoid re-processing unchanged files

Installation

npm install @saidksi/localizer-core
# or
pnpm add @saidksi/localizer-core

Quick Start

import { Scanner, AIClient, Rewriter, Validator } from "@saidksi/localizer-core";

// 1. Scan for hardcoded strings
const scanner = new Scanner({ defaultLanguage: "en" });
const results = await scanner.scan("./src");

// 2. Generate keys and translations
const aiClient = new AIClient({
  provider: "anthropic",
  apiKey: process.env.ANTHROPIC_API_KEY,
});
const translations = await aiClient.generateTranslations(results);

// 3. Rewrite source code
const rewriter = new Rewriter();
const modified = await rewriter.rewrite(filePath, results[0], translations);

// 4. Validate translations
const validator = new Validator();
const coverage = await validator.validate("./messages");

API

Scanner

Detects hardcoded strings in source code:

const scanner = new Scanner({
  defaultLanguage: "en",
  include: ["src/**/*.{ts,tsx,js,jsx}"],
  exclude: ["**/*.test.ts", "node_modules"],
  ignoreFiles: [],
});

const results = await scanner.scan(dirOrFilePath);
// Returns: ScanResult[] with { filePath, string, line, column, context }

AIClient

Generates semantic i18n keys and translations:

const client = new AIClient({
  provider: "anthropic" | "openai",
  apiKey: "your-api-key",
  model: "claude-3-sonnet" | "gpt-4",
});

const translations = await client.generateTranslations(scanResults, {
  languages: ["en", "fr", "es"],
  keyStyle: "dot.notation" | "snake_case",
  glossary: { /* domain-specific terms */ },
});
// Returns: { key: string, translations: { [lang]: string } }[]

Rewriter

Transforms source code to use i18n function calls:

const rewriter = new Rewriter();
const modified = await rewriter.rewrite(
  filePath,
  scanResult,
  translation,
  { 
    i18nLibrary: "react-i18next",
    dryRun: false,
  }
);
// Returns: { modified: string, diff: string }

Validator

Validates translation coverage:

const validator = new Validator({
  messagesDir: "./messages",
  languages: ["en", "fr"],
});

const report = await validator.validate();
// Returns coverage % per language and missing keys

Configuration

Create a .localizer.config.json in your project root:

{
  "defaultLanguage": "en",
  "languages": ["en", "fr", "es"],
  "messagesDir": "./messages",
  "include": ["src/**/*.{ts,tsx,js,jsx}"],
  "exclude": ["**/*.test.ts", "**/*.spec.ts"],
  "aiProvider": "anthropic",
  "aiModel": "claude-3-sonnet-20240229",
  "keyStyle": "dot.notation",
  "i18nLibrary": "react-i18next",
  "fileOrganization": "per-page",
  "strictMode": true,
  "glossary": {}
}

Development

# Install dependencies
pnpm install

# Build
pnpm build

# Tests
pnpm test
pnpm test:watch
pnpm test:coverage

# Type check
pnpm lint

License

MIT

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

Repository

https://github.com/SaidKSI/localizer-core