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
2.0.0

Highlights

Laratext 2.0 changes how laratext:scan keeps your translation files aligned with your source code. Drift between code and translation JSONs is now handled automatically by default, plus a new --prune flag cleans up orphan keys, and Anthropic's Claude joins OpenAI and Google as a built-in translator.

Breaking changes

Default scan behaviour now retranslates drifted keys

Before 2.0, running laratext:scan --write only translated brand-new keys. If you edited the source text of an existing key in your code, the translation files were left silently out of sync until you remembered to pass --resync.

In 2.0, the default scan also retranslates any key whose source text in code no longer matches the value stored in lang/{defaultLocale}.json. The drifted source and target translations are regenerated together, so your lang files stay aligned with the codebase without extra flags.

If you preferred the conservative behaviour, pass the new --only-missing flag (see below).

--resync now retranslates everything

--resync previously meant "retranslate keys whose source text drifted". That role is now the default, so --resync was repurposed: it now retranslates every key in your codebase from scratch, ignoring the existing translation files.

This is intended for one-off full regenerations, for example after switching translator providers or upgrading the underlying model. Expect it to be expensive in tokens.

New features

--only-missing flag translates only brand-new keys, leaving drifted keys untouched. Drift is still detected and printed as a warning showing the old vs. new source text, so you know what would be retranslated, but no API calls are made for drifted keys. Restores the pre-2.0 default behaviour for teams that want it.

php artisan laratext:scan --write --only-missing

--prune flag detects keys present in lang/{locale}.json files but no longer referenced anywhere in code (left over from removed text() or [@text](https://github.com/text) calls). By default it only lists them; combined with --write, it deletes them from every configured language file.

php artisan laratext:scan --prune              # list orphan keys only
php artisan laratext:scan --write --prune      # actually delete orphan keys

Claude (Anthropic) translator

A new ClaudeTranslator ships alongside the OpenAI and Google translators. It uses Anthropic's Messages API and defaults to claude-haiku-4-5 (override via the ANTHROPIC_MODEL env var). Prompt caching is enabled on the system prompt by default, so repeated batches in a single scan run reuse the cached instructions automatically.

Enable it per-run:

php artisan laratext:scan --write --translator=claude

Or set it as the project default in config/texts.php. The new config block:

  'claude' => [
      'api_key' => env('ANTHROPIC_API_KEY'),
      'model' => env('ANTHROPIC_MODEL', 'claude-haiku-4-5'),
      'timeout' => 60,
      'retries' => 3,
      'max_tokens' => 4096,
  ],

Other changes

Default OpenAI model bumped

The OpenAI translator's default model moves from the legacy gpt-3.5-turbo to gpt-5.4-nano, currently OpenAI's cheapest and fastest small model and a good fit for low-temperature JSON translation work. Override with the OPENAI_MODEL env var if you prefer a different model.

Migration

If you used laratext:scan --write in CI or automation expecting "only new keys, no drift handling", add --only-missing to keep that behaviour.

If you used --resync to fix drift, drop the flag, the default now does it.

If you want a full periodic cleanup, the modern recipe is:

php artisan laratext:scan --write --prune

Or, when changing translator or model:

 php artisan laratext:scan --write --resync
1.2.11
  • Keep priority on json translations over php arrays
1.2.10
  • Prevent nested JSON string
1.2.9

Add retries to wrongly decoded values

1.2.8

Fix Open AI when JSON is wrapped with markdown quotes

1.2.7
  • Support for single key texts
1.2.6
  • Added resync option
1.2.5
  • Allow to use text with just keys
  • Updated chatGPT prompt
1.2.1
  • Fixed text replacements for default texts.
  • Added text replacement tests
1.2
  • Now translations of multiple texts and languages are batched, making less requests to Google and OpenAI, being a more cost effective solution.
  • The optional translateMany method has been added to the translators. If not provided on the translators, it will perform many translate operations.
1.0.2

Fixed automated tranlations. Texts in the /test folder are no more scanned.

1.0.1

Support more laravel versions

1.0.0

First version

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.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
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