Artisan Commands - vsch/laravel-translation-manager GitHub Wiki
You can use artisan commands to do some translation management.
When providing a <group>
to a command for groups representing nested directories in the
language locale, you can use either the L5 /
or the L4 .
for separating directory names.
(Since version 2.0.30 for L5 or 1.0.30 for L4) In translation manager database groups always
have .
separator between directories.
The import command will load all translations in the resources/lang
directory.
$ php artisan translations:import
Note: By default, only new strings are added. Translations already in the DB are kept the same.
If you want to replace all values with the ones from the files, add the --replace
(or -R
)
option: php artisan translations:import --replace
The Find command and the web interface 'Add References' button will search for all php/twig files in the app directory for translation functions. It will do its best to extract the group/item names. If you have a lot of dynamically generated keys expect some false positives to show up in the database that you will need to delete via the web interface.
The found keys will be added to the database, so they can be easily translated. This can be done through the web interface, or via an Artisan command.
$ php artisan translations:find
This will attempt to find all source and view references to translation keys. The search is done
using regular expressions and some found keys may contain dynamic expressions. Keys that contain
quotes, ->
or $
if inside a double quoted string will be ignored because they are assumed to
be expressions computing the translation keys dynamically.
The export command will write the contents of the database back to app/lang php files. This will overwrite existing translations and remove all comments, so make sure to backup your data before using.
Supply the group name to define which groups you want to publish.
$ php artisan translations:export <group>
For example, php artisan translations:export reminders
when you have 2 locales (en/nl), will
write to resources/lang/en/reminders.php
and resources/lang/nl/reminders.php
The clean command will search for all translation that are NULL and delete them, so your interface is a bit cleaner. Empty translations are never exported to language files.
$ php artisan translations:clean
The reset command clears all translation in the database, so you can start fresh (by a new import). Make sure to export your work or download a zip archive of it, to make sure you don't irretrievably blow away your or someone else's work.
$ php artisan translations:reset