Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laratext Laravel Package

edulazaro/laratext

Laratext manages and auto-translates Laravel text strings by using both key and text for readable, stable translations. Includes @text directive and text() helper, scans/updates language files, and supports OpenAI, Google Translate, and more.

View on GitHub
Deep Wiki
Context7

A Laravel package to easily handle translated texts and translate them via AI or any translation service

Frequently asked questions about Laratext
How does Laratext differ from Laravel’s built-in __() translation helper?
Laratext combines the readability of inline text with the maintainability of translation keys by letting you define both (e.g., `@text('greeting', 'Hello, :name!')`). Unlike Laravel’s `__()` helper, it auto-translates missing keys via AI services while preserving placeholders like `:name`.
Which Laravel versions does Laratext support?
Laratext is designed for Laravel 9.x and 10.x. Check the package’s [Packagist page](https://packagist.org/packages/edulazaro/laratext) for the latest version’s compatibility notes. Always verify your Laravel version matches the package’s requirements.
Can I use Laratext with custom translation services beyond OpenAI/Google?
Yes, Laratext supports custom translators via the `TranslatorInterface`. Implement the interface and register it in the `config/texts.php` file under the `translators` array. This makes it extensible for private APIs or niche services.
How do I auto-translate existing language files with AI?
Run `php artisan laratext:scan` to identify missing translations, then use `php artisan laratext:translate` to auto-generate translations for supported languages. Configure your preferred translator (e.g., OpenAI) in `config/texts.php` first.
What’s the best way to handle API rate limits or failures during bulk translations?
Laratext includes retry logic configurable in `config/texts.php` (e.g., `retries` and `delay`). For production, consider queueing translations using Laravel Queues or implementing a fallback to cached translations if APIs fail.
Will Laratext break my existing translation files if I update the package?
Laratext is backward-compatible with Laravel’s language file structure (`resources/lang/`). However, running `php artisan laratext:resync` forces full retranslations, which may overwrite manual edits. Always back up files before major updates or use `--dry-run` to preview changes.
How do I integrate Laratext’s translations into Blade templates?
Use the `@text` directive (e.g., `@text('welcome', 'Welcome back, :user!')`) or the `text()` helper (e.g., `{{ text('error', 'Something went wrong') }}`). Both support placeholders and fall back to Laravel’s `__()` if the key isn’t found.
Are there alternatives to Laratext for Laravel AI translations?
Alternatives include `spatie/laravel-translatable` (for database-backed translations) or `laravel-lang/lang` (for static files). However, Laratext uniquely combines AI auto-translation with a hybrid key-text model, reducing manual effort while maintaining readability.
How do I test Laratext translations in a CI/CD pipeline?
Use `php artisan laratext:scan --test` to validate missing translations without auto-updating files. Mock AI services in tests by implementing a custom `TranslatorInterface` or using Laravel’s `MockTranslator` for isolated testing.
What’s the cost impact of using OpenAI/Google for bulk translations?
AI translation costs scale with usage. OpenAI’s API charges per token, while Google Translate uses pay-as-you-go pricing. Monitor usage with the provider’s dashboards and consider caching frequent translations or using free tiers for non-critical content.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope