- How do I install laravel-auto-translation in a Laravel app?
- Install it with composer require vildanbina/laravel-auto-translation, then publish the package config with the vendor:publish command. Add credentials for your chosen driver in the config or environment file, and apply the package trait to a single Eloquent model as a pilot. Because it is opt-in per model, you can scope the rollout to one low-risk content type before expanding.
- Which translation drivers does laravel-auto-translation support?
- The package supports OpenAI, Google Translate, and DeepL out of the box. Drivers sit behind a contract, so you can swap providers through configuration or add a custom driver if you need a different service. Each driver requires its own API credentials and has its own pricing and quota model, so cost per character at your content volume and locale count is worth checking before rollout.
- Does it translate Eloquent model attributes and language files?
- Yes. Applying the trait to a model makes its translatable attributes get translated automatically, and the package also ships commands to scan and translate JSON and PHP language files. That covers both database-driven content and static UI strings. Translation happens against a machine-translation provider, so output quality for domain-specific terminology should be reviewed by a human owner.
- Does laravel-auto-translation support Laravel 13?
- Release 2.2.2 widened the framework constraint to include Laravel 13, which makes it a forward-compatibility patch rather than a feature release. Confirm the patch did not also raise the minimum PHP or Laravel version, since a widened upper bound is safe but a raised floor would strand older apps. Also verify that the transitive provider SDKs your chosen driver depends on are themselves Laravel 13 compatible.
- Will automatic translation slow down my model saves?
- Default trait usage can perform a synchronous network round-trip to the provider during the save, which inflates write latency and turns a provider outage into a failed save. The package supports queues, and dispatching translation to a queue is strongly recommended for any production workload. With a queue in place, a provider timeout becomes a retried job instead of a user-facing error.
- How are translated values stored — JSON column or per-locale?
- Storage is configurable. The JSON-column mode stores translations alongside the model and requires no schema migration, while per-locale storage needs migrations and should be chosen up front because switching later is a data-migration task, not a config flip. Consider whether you need to query or sort by translated values, since the storage choice constrains that.
- Does the package cache translations to reduce API costs?
- Yes, caching is part of the feature set and helps avoid paying for the same string twice, which matters because machine-translation providers bill per character. Combined with queues, caching keeps latency and spend predictable at higher content volumes. Watch for cache invalidation when the source string changes, since a stale cache will keep serving the old translation.
- How do I test models that use auto-translation without hitting the provider API?
- Bind a fake implementation of the translation driver contract in the service container, or mock the driver, so your test suite never makes real provider calls. Tests should cover the missing-locale and untranslated-fallback paths as well as the happy path, since fallback behavior surfaces at runtime. Keep at least one integration test against a sandbox or low-volume credential to catch provider API changes.
- Is it safe to send user-generated content to OpenAI, Google, or DeepL?
- Translation transmits your content to a third-party provider, so the gating work is policy rather than engineering: data-egress review, DPA coverage, and cost sign-off. Identify PII-bearing fields and decide whether they need redaction before translation, or whether they should be excluded from the translatable attribute list. Get security and legal sign-off before applying the trait to any user-generated content model.
- Is laravel-auto-translation actively maintained, and what are the alternatives?
- Release 2.2.2 shows sustained maintenance and forward compatibility, but it is a single-maintainer package, so the bus factor is low; the small surface area mitigates this without eliminating it. For storage-only needs, spatie/laravel-translatable solves a different problem and is often used together with a translation service rather than instead of one. If you need vendor support or a managed translation workflow, a commercial localization platform may fit better.