laratoolkit / voyager-translator
Auto-translate Laravel lang/ files and Voyager CMS content using Gemini AI or Google Translate. Web UI included. Supports 15 languages.
Requires
- php: >=8.0
- illuminate/console: >=9.0
- illuminate/database: >=9.0
- illuminate/http: >=9.0
- illuminate/routing: >=9.0
- illuminate/support: >=9.0
README
Auto-translate your entire Laravel application — lang/ files (PHP + JSON) and Voyager CMS database content — using Gemini AI or Google Translate. Supports 15 languages with a built-in web UI.
Requirements
- PHP 8.0+
- Laravel 10, 11, 12 or 13
Installation
composer require laratoolkit/laravel-translator
PHP 8.5+ or dependency conflicts?
composer require laratoolkit/laravel-translator --ignore-platform-reqs
Publish the config (optional):
php artisan vendor:publish --tag=laravel-translator-config
Web UI
Open your browser at:
http://your-app.test/laravel-translator
Lang Files Tab
Translate your lang/ PHP and JSON files:
- Scan — detects all locales and key counts in your
lang/directory - Load Strings — loads all translatable strings for the selected source locale
- Select targets — choose which languages to translate into
- Choose engine — Google Translate (free) or Gemini AI
- Translate — real-time per-language progress bar
- Write to disk — saves directly to
lang/{locale}/OR Download ZIP — review before writing
Voyager / DB Tab
Translate Voyager CMS translations table entries (or any model table content via SQL dump):
- Load from DB or Upload SQL dump
- Source language auto-detected; select target languages
- Translate with real-time progress
- Save to DB, Download SQL, or Download JSON
Add
'auth'to themiddlewareconfig key to protect the UI route.
Artisan Command
# Translate lang/ files php artisan translate --mode=files --from=en --to=tr,es,ru,ar # Translate Voyager DB php artisan translate --mode=voyager --from=tr --to=en,es,ru # Use Gemini AI php artisan translate --mode=files --engine=gemini --from=en --to=tr,es # Only translate missing keys php artisan translate --only-missing # Preview without writing php artisan translate --dry-run
Configuration
# Engine: gemini or gtx (default: gtx) LARAVEL_TRANSLATOR_ENGINE=gemini # Required if engine=gemini GEMINI_API_KEY=your_key_here # Source locale (auto-detected in web UI) LARAVEL_TRANSLATOR_SOURCE=en # Target locales for Artisan command LARAVEL_TRANSLATOR_TARGETS=tr,es,ru,ar # Web UI route prefix (default: laravel-translator) LARAVEL_TRANSLATOR_PREFIX=laravel-translator
Supported Languages
| Code | Language | Code | Language |
|---|---|---|---|
| tr | Turkish | pt | Portuguese |
| en | English | it | Italian |
| es | Spanish | ja | Japanese |
| ru | Russian | ko | Korean |
| de | German | nl | Dutch |
| fr | French | pl | Polish |
| ar | Arabic | uk | Ukrainian |
| zh | Chinese |
How It Works
Lang Files Mode
- Scans
lang/{locale}/directories for PHP files and JSON files - Flattens nested arrays to
file.key→valuepairs - Protects Laravel placeholders (
:attribute,:name) and HTML tags during translation - Reconstructs nested structure and writes valid PHP array files or JSON files
Voyager / DB Mode
- Reads rows from the
translationstable (or parses a SQL dump) - Falls back to model table content if
translationstable is absent - Detects source language automatically from content
- HTML-safe translation with token protection
- Slug columns auto-transliterated (Turkish, Arabic, Cyrillic → Latin)
- Saves via
updateOrInsertor exports as SQL / JSON
Engines
Google Translate (GTX) — Free
No API key required. Works out of the box.
Gemini AI — Fast & Accurate
Uses gemini-2.5-flash with bulk requests (up to 60 items/call).
Get a free API key at Google AI Studio.
Standalone Version (React + TypeScript)
Looking for a standalone web app without Laravel? Check out the original version built with React, TypeScript & Vite — no server required, just open in browser:
voyager-translation-tool — Upload a SQL dump, auto-translate Voyager content, export SQL. Runs entirely in the browser.
License
MIT