Vibe i18n

A powerful i18n translation management CLI tool for Vue.js, Next.js, and other JavaScript projects. Designed for AI agents to efficiently manage translations without reading large locale files, saving tokens and preventing file corruption.

npx vibei18n

AI Agent Integration

For AI agents working with translations, use the CLI commands instead of reading/writing files directly to ensure data integrity and proper validation.

Prompt for AI Agents:

When working with i18n translations, ALWAYS use the CLI commands instead of reading or modifying locale files directly. This ensures proper validation, formatting, and prevents corruption.

Available commands for translation management:

  • Show help: npx vibei18n --help
  • Get translation: npx vibei18n get <locale> <key>
  • Set translation: npx vibei18n set <locale> <key> <value>
  • Check if exists: npx vibei18n has <locale> <key>
  • Get all locales for key: npx vibei18n getAll <key>
  • Find missing: npx vibei18n missing <key>
  • Check completeness: npx vibei18n check --detailed
  • Show statistics: npx vibei18n stats
  • List locales: npx vibei18n locales
  • Find hardcoded strings: npx vibei18n hardcode-check --verbose

Example workflow:

  1. Check current state: npx vibei18n stats
  2. Get specific translation: npx vibei18n get en-US common.loading
  3. Update translation: npx vibei18n set zh-hans common.loading "加载中..."
  4. Verify change: npx vibei18n get zh-hans common.loading

Powerful Features

Everything you need to manage translations efficiently and effectively

CLI

CLI-First Approach

Use npx vibei18n to manage translations with intuitive commands. Perfect for AI agents and automated workflows.

SCAN

Smart Locale Scanning

Automatically discovers locale files and provides insights into your translation coverage and completeness.

CHECK

Translation Completeness

Find missing translations across all locales with detailed reporting and prioritized suggestions.

DETECT

Hardcoded String Detection

Scan your codebase for hardcoded strings that should be internationalized. Skips code blocks intelligently.

STATS

Detailed Statistics

Get comprehensive insights into translation coverage, missing keys, and duplicate values across locales.

DUPE

Duplicate Detection

Find duplicate translations across locales and identify opportunities for consolidation and optimization.

API

Programmatic API

Use as a library in your Node.js projects for advanced automation and custom workflows.

JSON

Multiple Formats

Support for JSON and JS locale files with seamless conversion and validation capabilities.

Programmatic Usage

Use vibei18n as a library in your Node.js projects for advanced automation and custom workflows

Basic Setup

import { I18nHelper } from 'vibei18n';

// Initialize with default directory (./i18n/locales)
const helper = new I18nHelper();

// Or specify custom directory
const helper = new I18nHelper('./custom/locales');

Translation Operations

// Get all available locales
const locales = helper.getLocales();

// Get a translation
const value = helper.get('en-US', 'common.loading');

// Set a translation
helper.set('zh-hans', 'page.title', '页面标题');

Analysis & Validation

// Check completeness
const results = helper.checkTranslations(true);
console.log('Missing translations:', results.summary.totalMissing);

// Find hardcoded strings
const findings = helper.checkHardcodedStrings('./src', {
  extensions: ['.vue', '.js', '.ts'],
  verbose: true
});

Batch Updates

// Batch update multiple translations
helper.batchUpdate({
  'en-US': {
    'page.title': 'Page Title',
    'page.description': 'Page Description'
  },
  'zh-hans': {
    'page.title': '页面标题',
    'page.description': '页面描述'
  }
});