simonet85/laravel-deepl
Laravel integration for the DeepL translation API. Add your API key via config, then translate text between supported languages from your application using a simple, framework-friendly wrapper around DeepL's translation endpoints, including source and target language selection.
Architecture fit
DeepL facade + publishable config + two Artisan commands, wrapping the official deeplcom/deepl-php SDK rather than reimplementing the HTTP client. That is the right call — protocol churn is absorbed upstream.lang/{locale}.json, and (b) runtime DeepL::translate() calls. Mode (a) is low risk and clearly the designed-for path; mode (b) puts a paid, network-bound third party in the request path.lang/en/messages.php), Eloquent model translation, or DB-stored content — so scope is narrower than "translate the app."Integration feasibility
composer require simonet85/laravel-deepl, optional vendor:publish --tag=deepl-config, then a DeepL auth key in env. Free vs Pro inferred from the :fx key suffix — convenient, but means a key typo silently changes endpoint/billing tier behavior.Technical risk
:count and & < > are handled; undocumented is Laravel pluralization (trans_choice pipe syntax {0} …|[1,*] …), ICU-style tokens, %s-style sprintf strings, and Blade {{ }}. Also unverified: whether DeepL may legally reorder protected tokens in ways that break grammar.pt_BR/zh_CN ↔ DeepL PT-BR/ZH) needs explicit configuration; silent derivation will mis-target or fail at runtime.deepl:translate writes into source-controlled JSON. Needs atomic writes, stable key ordering (otherwise every run produces diff noise), and defined semantics for concurrent runs (two devs or CI + dev).--force is a governance footgun — it can overwrite human-reviewed copy with machine output. --scan= is heuristic and can pull unintended strings, inflating both cost and scope.--scan/--force and by number of locales. Batches of 50 matches DeepL's per-request cap, so large catalogs mean many sequential requests.Key questions
--scan= AST-based (Blade/PHP __() call detection) or regex? What is the false-positive profile?trans_choice pluralization pipes and ICU syntax protected?usage() hit the API or the cache, and is it per-key or account-wide?Stack fit
lang/*.json, with a DeepL Pro account (Pro is effectively required for glossaries, EU endpoint, and predictable billing).Migration path
php artisan deepl:translate fr --dry-run → review diff → real run → commit.--force is used — keep --force out of the default workflow.deeplcom/deepl-php; the package is thin enough that this is a realistic contingency.Compatibility
laravel-lang, IDE i18n plugins, and existing review tooling is fine — but assign clear ownership of lang/*.json to avoid write conflicts.Sequencing
--dry-run only.array), formality, context, explicit locale map.deepl:usage check with a monthly threshold alert.--scan and any --force usage, and restrict both to a single owning pipeline.Maintenance
Support
Scaling
translate() in request paths: it adds latency and makes your uptime a function of DeepL's. If runtime translation is genuinely needed, queue it and cache aggressively.Failure modes
--force clobbering reviewed copy; --scan capturing unintended strings; concurrent runs racing on the same JSON file.Ramp-up
--force is ever permitted, cache store choice, a maintained locale mapping table, and a mandatory review gate for machine output (especially marketing/legal copy where formality and terminology matter).How can I help you explore Laravel packages today?