|
| 1 | +Contributing Translations |
| 2 | +========================= |
| 3 | + |
| 4 | +Some Symfony Components include certain messages that must be translated to |
| 5 | +different languages. For example, if a user submits a form with a wrong value in |
| 6 | +a :doc:`TimezoneType </reference/forms/types/timezone>` field, Symfony shows the |
| 7 | +following error message by default: "This value is not a valid timezone." |
| 8 | + |
| 9 | +These messages are translated into tens of languages thanks to the Symfony |
| 10 | +community. Symfony adds new messages on a regular basis, so this is an ongoing |
| 11 | +translation process and you can help us providing the missing translations. |
| 12 | + |
| 13 | +How to Contribute a Translation |
| 14 | +------------------------------- |
| 15 | + |
| 16 | +Imagine that you can speak both English and Swedish and want to check if there's |
| 17 | +some missing Swedish translations to contribute them. |
| 18 | + |
| 19 | +**Step 1.** Translations are contributed to the oldest maintained branch of the |
| 20 | +Symfony repository. Visit the `Symfony Releases`_ page to find out which is the |
| 21 | +current oldest maintained branch. |
| 22 | + |
| 23 | +Then, you need to either download or browse that Symfony version contents: |
| 24 | + |
| 25 | +* If you know Git and prefer the command console, clone the Symfony repository |
| 26 | + and check out the oldest maintained branch (read the |
| 27 | + :doc:`Symfony Documentation contribution guide </contributing/documentation/overview>` |
| 28 | + if you want to learn about this process); |
| 29 | +* If you prefer to use a web based interface, visit |
| 30 | + `https://github.com/symfony/symfony <https://github.com/symfony/symfony>`_ |
| 31 | + and switch to the oldest maintained branch. |
| 32 | + |
| 33 | +**Step 2.** Check out if there's some missing translation in your language by |
| 34 | +checking these directories: |
| 35 | + |
| 36 | +* ``src/Symfony/Component/Form/Resources/translations/`` |
| 37 | +* ``src/Symfony/Component/Security/Core/Resources/translations/`` |
| 38 | +* ``src/Symfony/Component/Validator/Resources/translations/`` |
| 39 | + |
| 40 | +Symfony uses the :ref:`XLIFF format <best-practice-internationalization>` to |
| 41 | +store translations. In this example, you are looking for missing Swedish |
| 42 | +translations, so you should look for files called ``*.sv.xlf``. |
| 43 | + |
| 44 | +.. note:: |
| 45 | + |
| 46 | + If there's no XLIFF file for your language yet, create it yourself |
| 47 | + duplicating the original English file (e.g. ``validators.en.xlf``). |
| 48 | + |
| 49 | +**Step 3.** Contribute the missing translations. To do that, compare the file |
| 50 | +in your language to the equivalent file in English. |
| 51 | + |
| 52 | +Imagine that you open the ``validators.sv.xlf`` and see this at the end of the file: |
| 53 | + |
| 54 | +.. code-block:: xml |
| 55 | +
|
| 56 | + <!-- src/Symfony/Component/Validator/Resources/translations/validators.sv.xlf --> |
| 57 | +
|
| 58 | + <!-- ... --> |
| 59 | + <trans-unit id="91"> |
| 60 | + <source>This value should be either negative or zero.</source> |
| 61 | + <target>Detta värde bör vara antingen negativt eller noll.</target> |
| 62 | + </trans-unit> |
| 63 | + <trans-unit id="92"> |
| 64 | + <source>This value is not a valid timezone.</source> |
| 65 | + <target>Detta värde är inte en giltig tidszon.</target> |
| 66 | + </trans-unit> |
| 67 | +
|
| 68 | +If you open the equivalent ``validators.en.xlf`` file, you can see that the |
| 69 | +English file has more messages to translate: |
| 70 | + |
| 71 | +.. code-block:: xml |
| 72 | +
|
| 73 | + <!-- src/Symfony/Component/Validator/Resources/translations/validators.en.xlf --> |
| 74 | +
|
| 75 | + <!-- ... --> |
| 76 | + <trans-unit id="91"> |
| 77 | + <source>This value should be either negative or zero.</source> |
| 78 | + <target>This value should be either negative or zero.</target> |
| 79 | + </trans-unit> |
| 80 | + <trans-unit id="92"> |
| 81 | + <source>This value is not a valid timezone.</source> |
| 82 | + <target>This value is not a valid timezone.</target> |
| 83 | + </trans-unit> |
| 84 | + <trans-unit id="93"> |
| 85 | + <source>This password has been leaked in a data breach, it must not be used. Please use another password.</source> |
| 86 | + <target>This password has been leaked in a data breach, it must not be used. Please use another password.</target> |
| 87 | + </trans-unit> |
| 88 | + <trans-unit id="94"> |
| 89 | + <source>This value should be between {{ min }} and {{ max }}.</source> |
| 90 | + <target>This value should be between {{ min }} and {{ max }}.</target> |
| 91 | + </trans-unit> |
| 92 | +
|
| 93 | +The messages with ``id=93`` and ``id=94`` are missing in the Swedish file. |
| 94 | +Copy and paste the messages from the English file, translate the content |
| 95 | +inside the ``<target>`` tag and save the changes. |
| 96 | + |
| 97 | +**Step 4.** Make the pull request against the |
| 98 | +`https://github.com/symfony/symfony <https://github.com/symfony/symfony>`_ repository. |
| 99 | +If you need help, check the other Symfony guides about |
| 100 | +:doc:`contributing code or docs </contributing/index>` because the process is |
| 101 | +the same. |
| 102 | + |
| 103 | +.. _`Symfony Releases`: https://symfony.com/releases |
0 commit comments