The Gemini AI translator package for Laravel extracts translation keys in your Laravel project and translates them using Google’s Gemini AI agent. The package generates the necessary language files to translate your application quickly.
This package works by using an interactive CLI command that will scan your project, prompt you to select translation files to process, translate the strings using AI, and then generate translation keys.

Using the provided artisan command, you can specify languages you would like to translate your string into and other configuration options like chunking to determine how many keys to send to Gemini in each request:
# Basic usage with custom languagesphp artisan translations:extract-and-generate --langs=en,es,fr,de# High-performance processing with fork driver and smaller chunksphp artisan translations:extract-and-generate --driver=fork --chunk-size=50# Exclude additional directories and only scan Blade filesphp artisan translations:extract-and-generate --exclude=vendor,tests,docs --extensions=blade.php# Skip existing translations and use a different target directoryphp artisan translations:extract-and-generate --skip-existing --target-dir=resources/lang# Get help with all available optionsphp artisan help translations:extract-and-generate
Note: this package uses the Gemini 2.0 Flash-Lite model.
#Main Features
- Interactive Prompts: Interactively select which translation files (messages.php, validation.php, etc.) and JSON key prefixes to process.
- Powerful Key Extraction: Scans Blade, PHP, Vue, JS, and TypeScript files for translation keys using precise regular expressions.
- Intelligent Exclusions: Automatically ignores route() and config() helpers to prevent false positives.
- AI-Powered Translation: Uses the Gemini AI API to provide high-quality translations for multiple languages at once.
- Concurrency Support: Uses spatie/fork for parallel processing, making API calls significantly faster.
- Graceful Stop: Stop the translation process at any time by pressing a key (defaults to ‘q’).
- Detailed Logging: Creates a translation_extraction_log.json file detailing every key and where it was found, plus a failed_translation_keys.json for any errors.