【问题标题】:How to make proper module translations in Drupal 8?如何在 Drupal 8 中进行正确的模块翻译?
【发布时间】:2018-01-24 11:22:12
【问题描述】:

我必须准备模块翻译,但文档对我没有帮助。

我知道我可以使用 *.pot 文件,但我无法完全理解 dupal 是如何管理翻译的。

如果我添加翻译/example.pot,drupal 会处理其他所有事情吗?

【问题讨论】:

    标签: drupal-modules drupal-8 translation-scheme


    【解决方案1】:

    先修改module_name.info.yml 添加:

    '接口翻译项目': block_example '接口翻译服务器模式':modules/examples/%project/translations/%language.po

    然后在你的模块目录文件夹中创建translations

    添加 translations/language.po 文件,您将在其中存储翻译。

    语言.po:

    msgstr "你要翻译的 id" msgstr "翻译测试"

    template.html.twig:

    {% trans %}你要翻译的id{% endtrans %}

    然后转到您的 Drupal 管理页面配置/用户界面翻译,在那里您可以过滤您的 msgid 并查看已翻译的文件。

    您可能必须使用 IMPORT {只需上传 .po 文件} 安装模块时会自动导入翻译。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-24
      • 1970-01-01
      • 1970-01-01
      • 2018-11-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多