Reference
The commands
Everything is console-only. The service provider registers nothing at all unless
runningInConsole(), so there is no code from this package in a web request —
which is the incumbent's open question #445, "How can I use this lib in
production environment?"
translations:lint
php artisan translations:lint {locales?*}
--source=en # what the others are translations of
--only=... # missing,unused,placeholder,plural,empty,same
--except=...
--path=app --path=resources
--lang=lang
--json
Exits 1 when it finds anything, so it fails a build.
With no locales it checks every one it finds beside the source. --json prints
an array of {reason, locale, key, detail, file, line} for your own tooling.
translations:sync
php artisan translations:sync ar ur
--source=en
--copy # fill with the source text rather than blank
--lang=lang
--dry
Adds every key the source locale has, plus every key the code asks for. Never overwrites a value that exists.
translations:export
php artisan translations:export strings.csv {locales?*}
--source=en
--missing # only rows somebody has not done
--lang=lang
translations:import
php artisan translations:import strings.csv
--lang=lang
--force # let the spreadsheet win where both changed
--dry
What it writes
Sorted keys, nested arrays restored, short array syntax, real indentation:
<?php
return [
'nested' => [
'deep' => [
'key' => 'A deeply nested string',
],
],
'welcome' => 'Welcome, :name',
];
Sorting matters more than it looks: two translators working on different strings otherwise produce a conflict on every line.
A key with no dot in it, or one with a space, goes to lang/{locale}.json —
which is how Laravel itself tells the two kinds apart.
Nested arrays survive the round trip, which is the incumbent's #456. Export and import both go through one flattener, and there is a test that takes a three-level array out and back.