Skip to content

Multilingual-cli is a powerful NPM package that automatically scans your project for user-facing strings, extracts them into i18n translation files, and optionally translates them using DeepL or Google Translate.

License

Notifications You must be signed in to change notification settings

NagusameCS/Multilingual

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

31 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒ Multilingual CLI v2.0

Automated i18n with FREE translation options โ€” 15+ translation methods (12 free!), 37 languages, offline mode, multiple export formats, and more.

npm version License: MIT


โœจ What's New in v2.0

  • ๐Ÿ†“ 12 Free Translation Methods โ€” No billing required!
  • ๐Ÿ“‚ Offline Translation โ€” Built-in dictionaries, no internet needed
  • ๐ŸŽจ Creative Modes โ€” Pig Latin, Emoji, L33t, Morse Code, NATO phonetic
  • ๐Ÿ“Š Statistics & Cost Estimation โ€” Plan before you translate
  • ๐Ÿ“ฆ Multiple Export Formats โ€” XLIFF, PO/gettext, CSV, Android, iOS, ARB
  • ๐Ÿ‘€ Watch Mode โ€” Auto-translate during development
  • ๐Ÿงช Pseudo-localization โ€” Test UI with fake translations
  • ๐Ÿ’พ Translation Memory โ€” Reuse translations with fuzzy matching
  • ๐Ÿ”’ Enhanced Security โ€” API keys never exposed in logs

๐Ÿš€ Quick Start

# Install globally
npm install -g multilingual-cli

# Initialize in your project
multilingual init

# Or use directly with npx
npx multilingual-cli init

๐Ÿ“‹ Translation Services

๐Ÿ†“ FREE Online (No Billing Required)

Service Description Limit
MyMemory Crowd-sourced + machine translation (recommended) 10k chars/day (100k with email)
LibreTranslate Open source, self-hostable Unlimited
Lingva Privacy-focused (may be blocked by Cloudflare) Unlimited

๐Ÿ“‚ Offline (No Internet Required)

Service Description Use Case
Dictionary Built-in dictionaries for 10 languages Quick translations, no API
Local Use your own JSON translation files Custom terminology

๐ŸŽจ Creative & Testing (Instant)

Service Description Example
Pseudo Fake translations with accents [แธคแธ›ล€ล€ล‘ แบ†ล‘ล™ล€แธ“~~~]
Piglatin Classic word game ellohay orldway
Emoji Words โ†’ emojis ๐Ÿ‘‹ ๐ŸŒ
Leet L33t sp34k h3ll0 w0rld
Reverse Reversed text dlrow olleh
Mirror Unicode mirror chars ๊“ญโ…ƒ๊“คOW Oโ…ƒโ…ƒฦŽH
Morse Morse code .... . .-.. .-.. ---
NATO NATO phonetic alphabet Hotel Echo Lima Lima Oscar
Uppercase ALL CAPS HELLO WORLD

๐Ÿ’ณ Paid (Free Tier Available)

Service Description Free Tier
DeepL High quality neural translation 500k chars/month
Google Wide language support 500k chars/month
# Use free Lingva (recommended, no API key needed!)
multilingual translate-file -s en.json -o ./locales --service lingva

# Use offline dictionary (no internet required!)
multilingual translate-file -s en.json -o ./locales --service dictionary

# Fun: translate to Pig Latin
multilingual translate-file -s en.json -o ./locales --service piglatin

# View all service options
multilingual services

๐Ÿ› ๏ธ CLI Commands

Core Commands

multilingual init              # Interactive setup wizard
multilingual run               # Scan & translate project
multilingual scan              # Scan only, show strings
multilingual translate-file    # Translate existing JSON file

Export & Import

# Export to XLIFF for translation tools
multilingual export -i en.json -o translations.xliff -f xliff

# Import translated XLIFF
multilingual import -i translated.xliff -o fr.json

# Supported formats: xliff, xliff2, po, csv, android, ios, arb

Development Tools

multilingual watch             # Auto-translate on file changes
multilingual pseudo -s en.json # Generate pseudo-translations
multilingual stats             # View statistics & cost estimates

Configuration

multilingual config --show     # View current config
multilingual config --edit     # Interactive config editor
multilingual config --set key=value
multilingual services          # List all translation services
multilingual languages         # List all 37 supported languages

๐ŸŒ Supported Languages (37)

๐Ÿ‡บ๐Ÿ‡ธ English ๐Ÿ‡ช๐Ÿ‡ธ Spanish ๐Ÿ‡ซ๐Ÿ‡ท French ๐Ÿ‡ฉ๐Ÿ‡ช German
๐Ÿ‡ฎ๐Ÿ‡น Italian ๐Ÿ‡ต๐Ÿ‡น Portuguese ๐Ÿ‡ง๐Ÿ‡ท Portuguese (BR) ๐Ÿ‡ท๐Ÿ‡บ Russian
๐Ÿ‡จ๐Ÿ‡ณ Chinese (Simplified) ๐Ÿ‡น๐Ÿ‡ผ Chinese (Traditional) ๐Ÿ‡ฏ๐Ÿ‡ต Japanese ๐Ÿ‡ฐ๐Ÿ‡ท Korean
๐Ÿ‡ธ๐Ÿ‡ฆ Arabic (RTL) ๐Ÿ‡ฎ๐Ÿ‡ณ Hindi ๐Ÿ‡ณ๐Ÿ‡ฑ Dutch ๐Ÿ‡ต๐Ÿ‡ฑ Polish
๐Ÿ‡ธ๐Ÿ‡ช Swedish ๐Ÿ‡ฉ๐Ÿ‡ฐ Danish ๐Ÿ‡ซ๐Ÿ‡ฎ Finnish ๐Ÿ‡ณ๐Ÿ‡ด Norwegian
๐Ÿ‡น๐Ÿ‡ท Turkish ๐Ÿ‡จ๐Ÿ‡ฟ Czech ๐Ÿ‡ฌ๐Ÿ‡ท Greek ๐Ÿ‡ฎ๐Ÿ‡ฑ Hebrew (RTL)
๐Ÿ‡ญ๐Ÿ‡บ Hungarian ๐Ÿ‡ฎ๐Ÿ‡ฉ Indonesian ๐Ÿ‡ฒ๐Ÿ‡พ Malay ๐Ÿ‡น๐Ÿ‡ญ Thai
๐Ÿ‡ป๐Ÿ‡ณ Vietnamese ๐Ÿ‡บ๐Ÿ‡ฆ Ukrainian ๐Ÿ‡ง๐Ÿ‡ฌ Bulgarian ๐Ÿ‡ท๐Ÿ‡ด Romanian
๐Ÿ‡ธ๐Ÿ‡ฐ Slovak ๐Ÿ‡ธ๐Ÿ‡ฎ Slovenian ๐Ÿ‡ช๐Ÿ‡ช Estonian ๐Ÿ‡ฑ๐Ÿ‡ป Latvian
๐Ÿ‡ฑ๐Ÿ‡น Lithuanian

๐Ÿ“ฆ Export Formats

Supported Formats

Format Extension Use Case
JSON .json Web apps, Node.js
XLIFF 1.2 .xliff Translation tools (SDL, Trados)
XLIFF 2.0 .xliff Modern CAT tools
PO/gettext .po Linux, WordPress, Python
CSV .csv Spreadsheets, bulk editing
Android strings.xml Android apps
iOS .strings iOS/macOS apps
ARB .arb Flutter apps
# Convert JSON to XLIFF for professional translators
multilingual export -i en.json -o translations.xliff -f xliff

# Import back from translated XLIFF
multilingual import -i es.xliff -o es.json

๐Ÿงช Pseudo-localization

Test your UI's i18n readiness with fake translations:

# Generate pseudo-translations
multilingual pseudo -s en.json -o pseudo.json

Before: "Hello World" After: "[แธคแธ›ล€ล€ล‘ แบ†ล‘ล™ล€แธ“~~~]"

This helps you:

  • โœ… Find hardcoded strings
  • โœ… Test text expansion (~30% longer)
  • โœ… Verify special character support
  • โœ… Identify concatenated strings

๐Ÿ“Š Statistics & Cost Estimation

multilingual stats --report
โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘              Translation Statistics Report                    โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ

๐Ÿ“Š SUMMARY
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  Total strings:    245
  Total words:      1,847
  Total characters: 12,456
  Overall coverage: 78.3%

๐ŸŒ LANGUAGE COVERAGE
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  โœ… Spanish              [โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ] 100.0%
  ๐Ÿ”„ French               [โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘] 72.3%
  โณ German               [โ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘] 23.1%

๐Ÿ’ฐ COST ESTIMATES
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  DeepL Free tier: ~0.4 months of quota
  Google Free tier: ~0.4 months of quota
  โœ… Within free tier limits for both services

๐Ÿ”„ GitHub Actions Automation

multilingual github --setup

Automatically translate on every push:

# .github/workflows/translate.yml
name: Auto-translate
on:
  push:
    paths:
      - 'src/**'
      - 'locales/en.json'

jobs:
  translate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
      - run: npm install -g multilingual-cli
      - run: multilingual run --auto
        env:
          TRANSLATION_API_KEY: ${{ secrets.TRANSLATION_API_KEY }}
      - uses: stefanzweifel/git-auto-commit-action@v5
        with:
          commit_message: 'chore: update translations'

๐Ÿ’ป Programmatic Usage

import Multilingual, { 
  TranslationManager, 
  calculateStats,
  exportToFile,
  XLIFFFormat 
} from 'multilingual-cli';

// Basic usage
const ml = new Multilingual({
  config: {
    sourceLanguage: 'en',
    targetLanguages: ['es', 'fr', 'de'],
    translationService: 'none', // Use free service instead
  }
});

// Use free translation service
const manager = new TranslationManager();
manager.setExtendedService('libretranslate'); // No API key needed!

const result = await manager.translate('Hello World', 'es', 'en');
console.log(result.text); // "Hola Mundo"

// Pseudo-translation for testing
const pseudo = manager.generatePseudoTranslation('Hello World');
console.log(pseudo); // "[แธคแธ›ล€ล€ล‘ แบ†ล‘ล™ล€แธ“~~~]"

// Export to XLIFF
const doc = {
  sourceLanguage: 'en',
  targetLanguage: 'es',
  units: [
    { key: 'greeting', source: 'Hello', target: 'Hola' },
    { key: 'farewell', source: 'Goodbye', target: 'Adiรณs' },
  ]
};
const xliff = XLIFFFormat.export(doc);

๐Ÿ”’ Security

API keys are never exposed:

  • โœ… Keys masked in logs (AIza****...****V8Isd3A)
  • โœ… Uses environment variables
  • โœ… .env.example template included
  • โœ… Keys never written to translation files
  • โœ… Error messages sanitized
# Use environment variable
export TRANSLATION_API_KEY="your-key-here"
multilingual run --auto

๐Ÿ“ Project Structure

your-project/
โ”œโ”€โ”€ locales/
โ”‚   โ”œโ”€โ”€ en.json        # Source language
โ”‚   โ”œโ”€โ”€ es.json        # Auto-generated
โ”‚   โ”œโ”€โ”€ fr.json        # Auto-generated
โ”‚   โ””โ”€โ”€ ...
โ”œโ”€โ”€ .multilingual/
โ”‚   โ”œโ”€โ”€ translation-memory.json  # Reusable translations
โ”‚   โ””โ”€โ”€ reports/                 # Statistics reports
โ”œโ”€โ”€ multilingual.config.json     # Configuration
โ””โ”€โ”€ .env                         # API keys (git-ignored)

๐Ÿค Contributing

Contributions are welcome! Please read our contributing guidelines first.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“„ License

MIT License โ€” see LICENSE for details.

Attribution Required: Generated translation files must retain the multilingual-cli attribution comments.


๐Ÿ”— Links


Built with โค๏ธ by developers, for developers

About

Multilingual-cli is a powerful NPM package that automatically scans your project for user-facing strings, extracts them into i18n translation files, and optionally translates them using DeepL or Google Translate.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published