首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >国际化插件

国际化插件
EN

WordPress Development用户
提问于 2016-03-26 16:25:29
回答 1查看 31关注 0票数 0

我将部署我的第一个插件,但是_e()和__()函数似乎不起作用。

在我的评论标题中:

代码语言:javascript
复制
Text Domain: add-to-post-footer
Domain Path: /languages

我用poedit创建了.po和.mo文件,并将它们放在插件中的/languages中。我翻译成葡萄牙语,命名为'pt_BR.po/mo‘。在我的选项页中,有一些文本如下:

代码语言:javascript
复制
<?php echo __( 'With ', 'add-to-post-footer').ATPF_PLUGIN_NAME.__(' you can add some content at the final of all your posts without care about forget some of them, or the need to copy and paste boring proccess. Just go to Posts >> ', 'add-to-post-footer').ATPF_PLUGIN_NAME.__(', insert the content and save it. The proccess is the same to change the content. You just have to care about other stuff of your site/blog now', 'add-to-post-footer'); ?>

但是当我输入本地主机wordpress安装语言巴西葡萄牙语时,什么都不会发生(只需保存按钮,因为默认情况下已在WP上翻译了save )

我做错了什么?

EN

回答 1

WordPress Development用户

发布于 2016-03-26 16:46:49

您必须在插件中加载文本域:

代码语言:javascript
复制
<?php
function my_load_textdomain() {
    load_plugin_textdomain( 
        'add-to-post-footer', // text domain identifier
        false, // deprecated parameter
        plugin_basename(dirname( __FILE__ )) . '/languages' ); // path to the languages directory
}

add_action('plugins_loaded', 'my_load_textdomain');
票数 2
EN
页面原文内容由WordPress Development提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://wordpress.stackexchange.com/questions/221799

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档