如何在 Drupal 8 中进行正确的模块翻译?
How to make proper module translations in Drupal 8?
我必须准备模块翻译,但文档对我没有帮助。
我知道我可以使用 *.pot 文件,但我不能完全理解 dupal 如何管理翻译。
如果我添加 translations/example.pot drupal 会处理其他所有事情吗?
首先修改module_name.info.yml添加:
'interface translation project': block_example
'interface translation server pattern': modules/examples/%project/translations/%language.po*
然后在你的模块目录文件夹中创建 translations.
添加 translations/language.po 文件,您将在其中存储翻译。
language.po:
msgid "your id to translate"
msgstr "translations test"
template.html.twig:
<p>{% trans %}your id to translate{% endtrans %}</p>
然后转到您的 Drupal 管理页面 Configuration/User 界面翻译,在那里您可以过滤您的 msgid 并查看已翻译的文件。
您可能需要使用 IMPORT {只需上传 .po 文件}
安装模块时会自动导入翻译。
我必须准备模块翻译,但文档对我没有帮助。
我知道我可以使用 *.pot 文件,但我不能完全理解 dupal 如何管理翻译。
如果我添加 translations/example.pot drupal 会处理其他所有事情吗?
首先修改module_name.info.yml添加:
'interface translation project': block_example
'interface translation server pattern': modules/examples/%project/translations/%language.po*
然后在你的模块目录文件夹中创建 translations.
添加 translations/language.po 文件,您将在其中存储翻译。
language.po:
msgid "your id to translate"
msgstr "translations test"
template.html.twig:
<p>{% trans %}your id to translate{% endtrans %}</p>
然后转到您的 Drupal 管理页面 Configuration/User 界面翻译,在那里您可以过滤您的 msgid 并查看已翻译的文件。
您可能需要使用 IMPORT {只需上传 .po 文件} 安装模块时会自动导入翻译。