eugene-erg / laravel-google-informal-icu-i18n-translate
Laravel integration of the free Google Translate provider for eugene-erg/icu-i18n-translator
Package info
github.com/EugeneErg/laravel-google-informal-icu-i18n-translate
pkg:composer/eugene-erg/laravel-google-informal-icu-i18n-translate
Requires
- php: ^8.3
- eugene-erg/google-informal-icu-i18n-translator: ^3.0
- eugene-erg/laravel-icu-i18n-translate: ^3.0 || ^4.0
- guzzlehttp/guzzle: ^7.8
- illuminate/support: ^13.3
Requires (Dev)
- larastan/larastan: ^3.10
- laravel/pint: ^1.29
- orchestra/testbench: ^11.1
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.2
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.1
- phpstan/phpstan-strict-rules: ^2.1
- phpunit/phpunit: ^12.5
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-12-02 23:30:54 UTC
README
Adds the free Google Translate provider (eugene-erg/google-informal-icu-i18n-translator) to the Laravel translator (eugene-erg/laravel-icu-i18n-translate). Install it and the translator fills missing translations through Google. No API key is needed.
The informal endpoint has no SLA and can change or rate-limit at any time. Use it for development and drafts, and put a reliable provider before it for production.
composer require eugene-erg/laravel-google-informal-icu-i18n-translate
php artisan migrate # the tables of laravel-icu-i18n-translate
Requires PHP 8.3+, Laravel 13 and ext-intl. Both service providers are discovered automatically.
use EugeneErg\IcuI18nTranslator\Translator; $translator = app(Translator::class); $translator->translateMessage('Hello, {name}!', ['name' => 'Ivan'], toLocale: 'ru', fromLocale: 'en'); // "Привет, Ivan!": translated once, then read from the database
Files, formats and everything else are described in laravel-icu-i18n-translate and the core translator.
Configuration
The endpoint, for a proxy (config/services.php):
'google_informal_translate' => [ 'url' => env('GOOGLE_INFORMAL_TRANSLATE_URL', 'https://translate.googleapis.com'), ],
HTTP goes through Guzzle, and the list of Google languages is cached for a day in the default Laravel cache.
Bind your own Psr\Http\Client\ClientInterface, PSR-17 factories or Psr\SimpleCache\CacheInterface to
replace them.
Google is added at the end of TranslatorInterface::class . '[]'. To put another provider first:
$this->app->extend(TranslatorInterface::class . '[]', fn (array $translators) => [new MyProvider(), ...$translators]);
Upgrading to 2.x
- Requires
eugene-erg/laravel-icu-i18n-translate3.x or 4.x andeugene-erg/google-informal-icu-i18n-translator3.x (namedgoogle-informal-icu-i18n-translateup to 2.x). 1.x could not be installed with them. - The endpoint is read from
config('services.google_informal_translate.url'). 1.x read a config key namedGOOGLE_ICU_I18N_TRANSLATE_API_URL, which no config file defines. - The service provider is now discovered automatically (1.x declared it outside
extra). - Guzzle is a dependency instead of an optional default.
Development
composer check # pint, phpstan (level max), phpunit