php bin/console translation:extract
Extract missing translations keys from code to translation files.
Usage
translation:extract [--prefix [PREFIX]] [--format [FORMAT]] [--dump-messages] [--force] [--clean] [--domain [DOMAIN]] [--sort [SORT]] [--as-tree [AS-TREE]] [--] <locale> [<bundle>]
Arguments
locale The locale
bundle The bundle name or directory where to load the messages
Options
--prefix Override the default prefix
--format Override the default output format
--dump-messages Should the messages be dumped in the console
--force Should the extract be done
--clean Should clean not found messages
--domain Specify the domain to extract
--sort Return list of messages sorted alphabetically (only works with --dump-messages)
--as-tree Dump the messages as a tree-like structure: The given value defines the level where to switch to inline YAML
Help
The translation:extract command extracts translation strings from templates
of a given bundle or the default translations directory. It can display them or merge
the new ones into the translation files.
When new translation strings are found it can automatically add a prefix to the translation
message.
Example running against a Bundle (AcmeBundle)
php bin/console translation:extract --dump-messages en AcmeBundle
php bin/console translation:extract --force --prefix="new_" fr AcmeBundle
Example running against default messages directory
php bin/console translation:extract --dump-messages en
php bin/console translation:extract --force --prefix="new_" fr
You can sort the output with the --sort flag:
php bin/console translation:extract --dump-messages --sort=asc en AcmeBundle
php bin/console translation:extract --dump-messages --sort=desc fr
You can dump a tree-like structure using the yaml format with --as-tree flag:
php bin/console translation:extract --force --format=yaml --as-tree=3 en AcmeBundle