Translation Extractor
The translations:extract command scans PHP and Blade files for string-based translation helpers and
keeps your lang/<locale>.json files up to date. It lives in
App\Console\Commands\ExtractTranslations and can run against the whole project or a curated list of
folders.
Existing translations are never overwritten. Newly discovered keys are appended with the key itself as the
placeholder value so translators can fill them in later.
Signature & options
The command definition mirrors its usage examples, so what you see in the table below is exactly what the
$signature block declares:
php artisan translations:extract
--lang=en : Target language (resources/lang/<lang>.json)
--paths=* : Limit scan to one or more directories
--dry-run : Only show keys without writing any files
| Option | Type | Default | What it controls |
|---|---|---|---|
--lang= |
String | en |
Chooses which lang/<locale>.json file to update (or create if missing). |
--paths= |
Array of paths | app, resources/views |
Limits the scan to specific directories when you do not want to traverse the whole codebase. |
--dry-run |
Boolean flag | false |
Prints keys to the console instead of touching any files—perfect for CI or quick audits. |
Usage
Baseline extraction
php artisan translations:extract
Scans app/ and resources/views/, then updates lang/en.json.
French translations with custom folders
php artisan translations:extract --lang=fr --paths=app --paths=resources/views/components
Targets the French JSON file while limiting the scan to the application logic and Blade components.
Dry-run in CI
php artisan translations:extract --dry-run --paths=resources/views/pages
Lists the missing keys in the console so the pipeline can fail if translators need to catch up.
Where to find it
-
Command
app/Console/Commands/ExtractTranslations.php -
Language store
lang/<locale>.json