wordplate/polylang

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

WordPlate 的 Polylang 辅助工具

4.0.0 2018-03-12 15:09 UTC

This package is not auto-updated.

Last update: 2022-02-01 13:07:10 UTC


README

Polylang 提供的 WordPlate 辅助工具。

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