genius-asif / laravel-lang-ai-translate
A Laravel package to automate the translation from (en) language files to other languages using LLM APIs.
Fund package maintenance!
genius-asif
Requires
- php: ^8.3||^8.4
- illuminate/contracts: ^11.0||^12.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^2.9||^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^10.0.0||^9.0.0||^8.22.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-arch: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
- pestphp/pest-plugin-type-coverage: ^3.4
- phpstan/extension-installer: ^1.3||^2.0
- phpstan/phpstan-deprecation-rules: ^1.1||^2.0
- phpstan/phpstan-phpunit: ^1.3||^2.0
- rector/rector: ^2.0
README
Laravel Language AI Translate
Effortlessly translate your Laravel language files from English to multiple languages using powerful AI APIs like Google Gemini, OpenAI, and DeepSeek. Automate your localization workflow and reach a global audience with ease.
Key Features
- AI-Powered Translation: Leverage the capabilities of Google Gemini, OpenAI, and DeepSeek for accurate and efficient translations.
- Automated Workflow: Simplify your translation process by automating the translation of entire language files.
- Multiple Language Support: Translate to a wide range of languages supported by the integrated AI APIs.
- Easy Integration: Seamlessly integrate into your Laravel project with a simple Artisan command.
- Configurable Providers: Easily switch between different AI translation providers based on your needs and preferences.
Prerequisites
- PHP 8.3 or higher
- Laravel 11 or higher
Installation
You can install the package via Composer:
composer require genius-asif/laravel-lang-ai-translate
Publish the configuration file:
php artisan vendor:publish
This will create a config/lang-ai-translation.php
file where you can configure your LLM API keys and language settings.
Configuration:
Open the config/lang-ai-translation.php
file and add your API keys for the desired translation providers:
<?php return [ 'languages' => [ 'hi' => 'Hindi', 'es' => 'Spanish', 'fr' => 'French', 'ur' => 'Urdu', ], 'providers' => [ 'google_gemini' => [ 'key' => env('GOOGLE_GEMINI_API_KEY', ''), 'url' => env('GOOGLE_GEMINI_API_URL', '[https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=](https://www.google.com/search?q=https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent%3Fkey%3D)' . env('GOOGLE_GEMINI_API_KEY')), ], 'openai' => [ 'key' => env('OPENAI_API_KEY', ''), 'url' => env('OPENAI_API_URL', '[https://api.openai.com/v1/chat/completions](https://api.openai.com/v1/chat/completions)'), ], 'deepseek' => [ 'key' => env('DEEPSEEK_API_KEY', ''), 'url' => env('DEEPSEEK_API_URL', '[https://api.deepseek.com/chat/completions](https://api.deepseek.com/chat/completions)'), ], ], ];
Ensure you add the corresponding API keys to your .env
file.
Usage
Use the following Artisan command to translate your language files:
php artisan translate:lang
The command will prompt you to:
- Select the target language.
- Choose the AI translation provider.
The package will then automatically translate your language files from the lang/en
directory to the selected language directory.
Testing
Coming soon...
Contributing
We'd love your help making the package even better! Feel free to submit a pull request or open an issue for any enhancements or bug fixes. Everyone's welcome! 🎉
Credits
License
This project is licensed under the MIT License.