Laravel manager for translators. WIP.
Includes drivers for:
- Azure AI Translator
- DeepL
- Google Translate - v2 and v3.
- OpenAI
The OpenAI driver is the default, which can be changed easily.
You must still install the package with the driver you want to use:
composer require datashaman/laravel-translators openai-php/client // for OpenAI
composer require datashaman/laravel-translators google/cloud-translate // for Google Translate
composer require datashaman/laravel-translators deeplcom/deepl-php // for DeepL Translator
The Azure AI Translator driver uses the REST API, so no additional packages are required:
composer require datashaman/laravel-translators
You can publish the config file if you wish to customize it in some way:
php artisan vendor:publish --tag="laravel-translators-config"
This is not necessary if you are using the default configuration.
use Datashaman\LaravelTranslators\Facades\Translator;
// Default is OpenAI
$translations = Translator::translate(['Hello, world!'], 'fr'); // ["Bonjour, monde !"]
$translations = Translator::driver('azure')->translate(['Hello, World!'], 'fr'); // ["Salut tout le monde!"]
$translations = Translator::driver('deepl')->translate(['Hello, World!'], 'fr'); // ["Bonjour à tous !"]
$translations = Translator::driver('google-v2')->translate(['Hello, World!'], 'fr'); // ["Bonjour le monde!"]
$translations = Translator::driver('google-v3')->translate(['Hello, World!'], 'fr'); // ["Bonjour le monde!"]
The default driver is OpenAI. You can change the default driver (set TRANSLATOR_DRIVER
in your .env
file).
There are various configuration requirements per service to setup before they can be used. There is an example .env file with all the configuration options. You are also free to modify the config and environment variables (once config is published) to suit your own schema.
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.