Translate Your App to Other Languages With Laravel Gemini Translator

Translate Your App to Other Languages With Laravel Gemini Translator

Translate Your App to Other Languages With Laravel Gemini Translator

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.

Example output using the laravel-gemini-translator package.
Example output using the laravel-gemini-translator package.

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.

Freelance web based advanced application development

Get developer support for your laravel project

author avatar
abina35@gmail.com
Abin Antony Location: Kerala, India Professional Summary: Abin Antony is a seasoned Laravel developer with over 8 years of experience in crafting efficient and scalable web applications. Specializing in Eloquent ORM, Abin has a strong background in developing complex systems with a focus on performance and maintainability. Currently, Abin is running a tech company called Edgesys Technologies, where he leads projects that integrate advanced web technologies with user-centric design principles. Current Projects: Developing a mobile app with comprehensive technical and non-technical documentation. Working on a diet food subscription platform named PRO CALORIES in Kochi, focusing on enhancing user engagement and SEO optimization. Expertise: Laravel Framework Eloquent ORM Raw SQL Queries in Laravel Web Development Proposals Feel free to let me know if you’d like any changes or additional details!

Leave a Reply

Your email address will not be published. Required fields are marked *