Skip to content

Add some documentation about extraction #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion symfony/extracting-translations.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,38 @@
Extracting Translations from Source
===================================

TODO example how to extract source. Show different configurations and commands.
Extracting translations from your project
-----------------------------------------

.. code-block:: yaml

translation:
locales: ["en", "fr", "sv"]
configs:
app:
dirs: ["%kernel.root_dir%/Resources/views", "%kernel.root_dir%/../src"]
output_dir: "%kernel.root_dir%/Resources/translations"
excluded_names: ["*TestCase.php", "*Test.php"]
excluded_dirs: [cache, data, logs]

With the configuration above you may extract all translation keys from your
source code by running

.. code-block:: bash

php bin/console translation:extract app

Extracting translations from a bundle
-------------------------------------

If you're using a bundle shipped with custom translations, you can extract
them using ``external_translations_dir``.

For example, with `FOSUserBundle<https://github.com/FriendsOfSymfony/FOSUserBundle/>`:

.. code-block:: yaml

translation:
configs:
app:
external_translations_dir: ["%kernel.root_dir%/vendor/friendsofsymfony/user-bundle/Resources/translations"]
4 changes: 2 additions & 2 deletions symfony/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ Below is an example of configuration that is great to start with.
excluded_names: ["*TestCase.php", "*Test.php"]
excluded_dirs: [cache, data, logs]

With the configuration above you may extract all translation key from your source
code by running
With the configuration above you may extract all translation keys from your
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bocharsky-bw I also corrected this file according to your comment as I copy pasted the first part of the symfony / extraction documentation from here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍

source code by running

.. code-block:: bash

Expand Down