GoogleTranslateToolkit v2.0 · Laravel 12–13 · PHP 8.3+ · MIT

Every language, on the board.

Google Translate for Laravel, built the way the rest of your application is built — a fluent builder, a cache that means most translations never leave your server, and placeholders that survive the round trip.

Get started → See how it works $ composer require gabrielesbaiz/google-translate-toolkit
Now showing Italiano · it Source auto-detected Board cycles 6 of 137 languages
FRHello worldBonjour le monde0.4 msCACHE
DEHello worldHallo Welt0.4 msCACHE
JAHello worldこんにちは世界186 msAPI
ARHello worldمرحبا بالعالم0.3 msCACHE
137 languages0 SDK dependencies94 tests, no networkPHPStan level 6
0
Languages, typed
0
Typical cache hit rate
0
Artisan commands
0
Tests, zero network
What it does

Four HTTP endpoints. Everything hard happens around them.

Calling the Translation API is easy. Paying for the same string twice, losing a placeholder, failing a queued job because Google had a bad minute — that is the part a package should take off your hands.

Cache first

The bill you don't get

Cached segments never reach the API, and a batch of a hundred strings only sends the ones it has not seen. Keyed by source, target, format and text, for 30 days.

Placeholders

They come back intact

Ten patterns are masked before the call and restored after — :name, {count}, {{ $blade }}, %s, URLs, e-mails, handles and code spans.

Glossary

Your brand stays yours

Protected terms never reach Google at all. Forced wording is applied on the way back, word-bounded and case-preserving, per locale.

Fan-out

Many languages, one pool

to(['it','fr','de']) sends every chunk through a single bounded Http::pool(), groups targets that share cache misses, and returns a collection keyed by locale.

Resilience

A bad minute isn't an outage

Timeouts, retry with backoff on 429 and 5xx, an optional rate limiter, and onFailUseSource() so a webhook stores the original text instead of failing.

Testing

A fake with assertions

GoogleTranslate::fake() returns deterministic text and records everything, so assertTranslated() reads like the rest of your suite. Nothing touches the network.

In your code

A builder that reads like Laravel.

Immutable, so a configured builder is safe to share. Every modifier returns a new instance; nothing happens until a terminal method runs.

translate.phpruns as shown
use Gabrielesbaiz\GoogleTranslateToolkit\Facades\GoogleTranslate;

// The short way — source auto-detected, target from config
GoogleTranslate::justTranslate('The message bounced');
// "Il messaggio è stato rifiutato"

// The full object
$translation = GoogleTranslate::from('en')->to('it')->translate('Good morning');

$translation->translatedText;   // "Buongiorno"
$translation->sourceLanguage;   // "en" — detected by Google
$translation->cached;           // false the first time, true after

// Many languages, one pooled fan-out
GoogleTranslate::to(['it', 'fr', 'de'])->translate('Good morning');
// Collection keyed by locale
Where your string actually goes

Six stops. Four of them are free.

A single call through the package, in order. Only the fifth stop is billed, and only for the segments the cache could not answer.

Routingtranslate("Welcome back, :name") → it1 of 4 segments billed
01

Mask

:name is swapped for a sentinel Google will not touch. The glossary's protected terms go with it.

0 ms
02

Cache partition

The batch splits into hits and misses. Three of four segments are answered locally and never leave the process.

HIT ×3
03

Budget guard

The remaining characters are counted against the daily ceiling. Over it, the call throws before a request is built.

1 208 chars
04

Chunk and pool

Segments are split by count and by characters, then sent concurrently through one bounded pool.

1 request
05

Translate v2

The only billed stop. The key travels in a header, retries fire on 429 and 5xx, and a failure can fall back to the source text.

186 ms
06

Restore

Sentinels become placeholders again, glossary overrides are applied, the result is cached and the event fires.

0 ms
Departures

Eight commands. No guesswork.

Translate a string, a lang file or a whole table — and price any of it before you spend a character.

php artisan8 commands
translate:textTranslate strings from the console. --dry-run prices it instead.ON TIME
translate:languagesList every supported language. --offline skips the API entirely.ON TIME
translate:langTranslate lang/{from} into other locales, skipping lines that already exist.ON TIME
translate:modelBackfill a model's translated columns, chunked, optionally queued.BOARDING
translate:auditBack-translate existing lang lines and flag the ones that lost their meaning.ON TIME
translate:costPrice a translation before spending, from arguments or a file.ON TIME
translate:statsVolume, cache hit rate and estimated spend, by day.ON TIME
translate:cache-clearInvalidate everything the package cached, without touching the rest of your store.ON TIME
Cost control

The cheapest translation is the one you already paid for.

Google bills per million characters, per target language. The package counts what it spends, estimates before it spends it, and refuses to cross a ceiling you set.

Characters from cache
0
last 30 days
Not spent
$0
at $20.00 per million
Daily ceiling
0
throws before the request is built
php artisan translate:stats --days=4
datecallscharacterscache hitshit ratefailurescost
2026-09-204162 11838890.4%0$1.24
2026-09-211218 40241997.2%0$0.37
2026-09-22911 08840297.8%1$0.22
2026-09-2367 64051198.8%0$0.15
The shelf

137 languages, as an enum.

Normalised (ZH_tw → zh-TW), validated, labelled, and honest about which nine read right to left.

⭐FREE

Star the repo

Thirty seconds, and it is the first signal other developers look at when deciding whether to trust a package.

🐛FREE

Open a good issue

A clear reproduction is worth more than you think. Several fixes in 2.0 started as somebody else's bug report.

❤️

Sponsor from $5

Goes towards the maintenance nobody sees: framework upgrades, new language codes, and keeping the test matrix green.

🏢

Company tier

Your logo here and in the README. If this package translates what your customers read, it is cheaper than the week you would spend rebuilding it.

♥

Why ask at all? This package is MIT and always will be. Nothing is paywalled, nothing phones home, and no feature is held back for sponsors. Sponsorship buys maintenance time, not features — and if you cannot sponsor, the star and the bug report genuinely help.