A new tool to manage your i18n locale files



This content originally appeared on DEV Community and was authored by Alexis Clarembeau

🌐 CLI18n: The Translation Management Tool Your JavaScript Project Needs

Managing internationalization (i18n) in JavaScript projects can be a real pain. Scattered translation keys, duplicate values, unused translations cluttering your locale files, and the constant back-and-forth between code and translation files. Sound familiar?

I’ve been working on CLI18n – a powerful CLI tool that tackles these exact problems and makes managing translations actually enjoyable.

What is CLI18n?

CLI18n is a comprehensive internationalization management tool that helps you extract, organize, and maintain translation keys in your JavaScript projects. Think of it as your i18n Swiss Army knife.

🚀 Key Features

  • 🔍 Smart Key Extraction: Automatically scan your codebase and extract translation keys using customizable regex patterns
  • 🔄 Duplicate Detection: Find duplicate translations across locale files to maintain consistency
  • 🗑 Cleanup Tools: Remove unused translations to keep your locale files clean
  • 🌐 Web Interface: Beautiful, responsive web UI for managing translations
  • ⚡ Real-time Editing: Edit translations with instant file updates
  • 🎯 Smart Filtering: Focus on untranslated keys or search specific terms
  • 📱 Mobile-Friendly: Works seamlessly on any device

Getting Started

Installation

# Global installation
npm install -g cli18n

# Or use locally
npm install --save-dev cli18n

# Or run without installing
npx cli18n extract

Quick Setup

Create a cli18n.json in your project root:

{
  "regex": "t\\('([^']*)'\\)",
  "outputDir": "locales/{{lang}}.json",
  "languages": ["en", "fr", "es", "de"]
}

💡 Real-World Usage

1. Extract Translation Keys

cli18n extract

This scans your entire codebase, finds patterns like t('welcome.message'), and automatically generates/updates your locale files while preserving existing translations.

2. Find Duplicate Translations

cli18n duplicates

Ever had the same translation value scattered across different keys? This command finds them all, helping you maintain consistency and reduce redundancy.

3. Clean Up Unused Keys

cli18n prune-unused

Over time, translation keys pile up. This command removes keys that are no longer referenced in your codebase, keeping your locale files lean and maintainable.

4. Visual Translation Management

cli18n serve

This launches a beautiful web interface where you can:

  • Browse all translation keys in a clean table
  • Edit translations inline with auto-save
  • Filter by language or search for specific keys
  • Focus on untranslated keys (highlighted in red)
  • Work on mobile or desktop

🎯 Perfect For These Scenarios

Migrating an existing project to i18n? CLI18n can scan your entire codebase and extract all the hardcoded strings you need to translate.

Working with a translation team? The web interface makes it easy for non-technical team members to contribute translations.

Maintaining a large multilingual app? The duplicate detection and cleanup tools keep your translations organized as your project grows.

Starting a new international project? Set up your i18n workflow from day one with automated extraction and management.

Example Project Structure

my-project/
├── cli18n.json
├── src/
│   ├── components/
│   │   └── Header.js       // t('nav.home'), t('nav.about')
│   └── pages/
│       └── Login.js        // t('login.title'), t('login.submit')
└── locales/
    ├── en.json             // Auto-generated
    ├── fr.json             // Auto-generated
    └── es.json             // Auto-generated

🛠 Programmatic API

You can also integrate CLI18n into your build process:

const { extractTranslations, findDuplicateTranslations } = require('cli18n');

// In your build script
await extractTranslations();
await findDuplicateTranslations();

Why I Built This

After working on several international JavaScript projects, I kept running into the same issues:

  • Manual translation key management was error-prone
  • Finding unused translations was nearly impossible
  • Non-technical team members struggled with JSON files
  • Duplicate translations created inconsistent UX

CLI18n solves all these problems with a workflow that actually scales.

What’s Next?

I’m actively working on CLI18n and have some exciting features planned:

  • Integration with popular translation services
  • VS Code extension for inline translation editing
  • Advanced analytics and translation progress tracking
  • Support for more file formats beyond JSON

Try It Today!

npx cli18n extract

That’s it! CLI18n will guide you through the setup and start managing your translations immediately.

Links:

Have you tried CLI18n? What i18n challenges are you facing in your projects? Let me know in the comments!


This content originally appeared on DEV Community and was authored by Alexis Clarembeau