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

@vocoder/cli

v0.1.2

Published

CLI tool for Vocoder translation workflow

Downloads

29

Readme

@vocoder/cli

CLI tool for the Vocoder translation workflow. Extract translatable strings from your React code and get them translated automatically.

Installation

npm install -D @vocoder/cli
# or
pnpm add -D @vocoder/cli
# or
yarn add -D @vocoder/cli

Quick Start

  1. Set up environment variables (create .env in your project root):
VOCODER_API_KEY=your-api-key-here
  1. Add to your build script:
{
  "scripts": {
    "prebuild": "vocoder sync",
    "build": "next build"
  }
}
  1. Use <T> components in your code:
import { T } from '@vocoder/react';

function MyComponent() {
  return (
    <div>
      <T>Welcome to our app!</T>
      <T name={userName}>Hello, {name}!</T>
    </div>
  );
}
  1. Run the CLI:
npx vocoder sync

This will:

  • Extract all <T> components from your code
  • Submit them to Vocoder for translation
  • Download translations to .vocoder/locales/*.json
  • Only translate NEW strings (incremental updates are fast!)

Configuration

The CLI uses environment variables for configuration:

Required

  • VOCODER_API_KEY: Your Vocoder API key (get from https://vocoder.dev)

Optional (Development Only)

  • VOCODER_API_URL: Override API endpoint (defaults to https://api.vocoder.dev)

Defaults (Not Configurable)

  • Target locales: es, fr, de
  • Extraction pattern: src/**/*.{tsx,jsx,ts,js}
  • Output directory: .vocoder/locales
  • Target branches: main, master, production, staging

To customize these defaults, configure them in your Vocoder dashboard.

Commands

vocoder sync

Extract and translate strings.

npx vocoder sync [options]

Options:

  • --branch <name> - Specify branch name (auto-detected from git)
  • --force - Translate even if not on a target branch
  • --dry-run - Show what would be translated without making API calls
  • --verbose - Show detailed output

Examples:

# Normal usage (auto-detects branch from git)
npx vocoder sync

# Specify branch manually
npx vocoder sync --branch feature/new-ui

# See what would be translated without making API calls
npx vocoder sync --dry-run

# Force translation even if not on a target branch
npx vocoder sync --force

# Verbose output for debugging
npx vocoder sync --verbose

Workflow

First Run (100 strings)

$ npx vocoder sync
✓ Detected branch: main
✓ Loaded config for project: abc123
✓ Extracted 100 strings from src/**/*.{tsx,jsx,ts,js}
✓ Submitted to API - Batch ID: batch-xyz
  Found 100 new strings to translate
⏳ Translating to 3 locales (es, fr, de)
  Estimated time: ~30 seconds
✓ Translations complete!
✓ Wrote 3 locale files

✅ Translation complete! (32.4s)

Second Run (Same strings, 0 new)

$ npx vocoder sync
✓ Detected branch: main
✓ Loaded config for project: abc123
✓ Extracted 100 strings from src/**/*.{tsx,jsx,ts,js}
✓ Submitted to API - Batch ID: batch-abc
  Found 0 new strings to translate

✅ No new strings - using existing translations
✓ Wrote 3 locale files

✅ Translation complete! (0.8s)

Incremental Run (1 new string)

$ npx vocoder sync
✓ Detected branch: main
✓ Loaded config for project: abc123
✓ Extracted 101 strings from src/**/*.{tsx,jsx,ts,js}
✓ Submitted to API - Batch ID: batch-def
  Found 1 new strings to translate
⏳ Translating to 3 locales (es, fr, de)
  Estimated time: ~1 seconds
✓ Translations complete!
✓ Wrote 3 locale files

✅ Translation complete! (1.2s)

Branch-Scoped Translations

Translations are isolated per git branch:

  • Main branch translations are shared across the team
  • Feature branches get their own translations
  • Feature branches fall back to main branch translations
  • Merge to main to promote feature translations

This allows you to:

  • Test translations in feature branches
  • Preview translations before merging
  • Avoid conflicts between features

Performance

The CLI is optimized for incremental updates:

| Scenario | Time | Cost | |----------|------|------| | 100 new strings | ~30s | 100 strings × 3 locales | | 0 new strings | <1s | No API calls | | 1 new string | ~1s | 1 string × 3 locales |

Speedup: 30x faster for incremental updates!

Output

Translations are written to .vocoder/locales/:

.vocoder/
└── locales/
    ├── es.json
    ├── fr.json
    └── de.json

Each file contains a flat key-value mapping:

{
  "Welcome to our app!": "¡Bienvenido a nuestra aplicación!",
  "Hello, {name}!": "¡Hola, {name}!",
  "You have {count} messages": "Tienes {count} mensajes"
}

Add to .gitignore:

.vocoder/

Translations are generated at build time, not checked into git.

Integration with React

Use the generated locale files with @vocoder/react:

import { VocoderProvider } from '@vocoder/react';
import en from './.vocoder/locales/en.json';
import es from './.vocoder/locales/es.json';
import fr from './.vocoder/locales/fr.json';

export default function App({ children }) {
  return (
    <VocoderProvider
      translations={{ en, es, fr }}
      defaultLocale="en"
    >
      {children}
    </VocoderProvider>
  );
}

Troubleshooting

"VOCODER_API_KEY is required"

Create a .env file in your project root:

VOCODER_API_KEY=your-api-key

"No translatable strings found"

Make sure you're using <T> components from @vocoder/react:

import { T } from '@vocoder/react';

// ✅ Good
<T>Welcome!</T>

// ❌ Bad (not detected)
<span>Welcome!</span>

"Not a git repository"

The CLI auto-detects the branch from git. Either:

  • Initialize git: git init
  • Specify branch manually: vocoder sync --branch main

"Skipping translations (not a target branch)"

The CLI only runs on target branches (main, master, production, staging) by default. Either:

  • Merge to a target branch
  • Use --force flag: vocoder sync --force

Development

# Install dependencies
pnpm install

# Build
pnpm build

# Run tests
pnpm test

# Run unit tests only (fast)
pnpm test:unit

# Run integration tests (requires API)
pnpm test:integration

# Watch mode
pnpm test:watch

License

MIT