'How to make proper module translations in Drupal 8?

I have to prepare modules translations, but the documentation is not helping me.

I know i can use *.pot files, but i can't fully understand how dupal is managing translations.

If i add translations/example.pot drupal will take care of everything else?



Solution 1:[1]

First modify module_name.info.yml add:

'interface translation project': block_example
'interface translation server pattern': modules/examples/%project/translations/%language.po*

Then create in your module directory folder translations.

Add translations/language.po files, where you will store translations.

language.po:

msgid "your id to translate"
msgstr "translations test"

template.html.twig:

<p>{% trans %}your id to translate{% endtrans %}</p>

Then go to your Drupal admin page Configuration/User interface translation, there you can filtr your msgid and see already translated files.

You may have to use IMPORT {just upload .po file} Translations are imported automatically when you install your module.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 cweiske