hoy / polylang
WordPlate的Polylang辅助工具
4.0.0
2018-03-12 15:09 UTC
This package is not auto-updated.
Last update: 2024-09-20 05:32:58 UTC
README
安装
使用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的文档以了解更多关于翻译您的帖子类型的信息。