wordplate/translator

此包已被废弃且不再维护。作者建议使用 hoy/polylang 包。

WordPlate 的 Polylang 辅助工具

4.0.0 2018-03-12 15:09 UTC

This package is not auto-updated.

Last update: 2022-02-01 12:58:18 UTC


README

WordPlate 的 Polylang 辅助工具。

Build Status StyleCI Coverage Status Latest Version License

安装

使用 Composer,在项目根目录中要求此包。

$ composer require hoy/polylang

登录到 WordPress 管理员仪表板并激活 Polylang 插件。转到 Polylang 设置页面并添加至少一种语言。

使用方法

使用 pll_translations 函数注册翻译。现在它们将在 WordPress 管理员仪表板的“字符串翻译”页面上可用于翻译。

pll_translations([
    'group' => [
        'String that should be translatable by Polylang' => 'Explanation of how the string is used',
    ],
    'general' => [
        'English' => 'The english language',
        'Swedish' => 'The swedish language',
    ],
    'cookie-bar' => [
        'This website uses cookies to ensure you get the best experience on our website.' => 'Cookie bar message',
        'I understand' => 'Cookie bar button text'
    ],
]);

然后,要获取并打印翻译,您可以使用 trans 函数,就像使用常规的 __() 函数一样。

echo trans('I understand');

文档

请访问 Polylang 的文档,了解更多关于翻译您的帖子类型的信息。

许可

MIT © Hoy Multimedia AB