最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How can I translate the name of my Plugin for other languages?

programmeradmin2浏览0评论

How can I translate the name of plugin for other languages? For example:

When Wordpress is in pt-BR language, the plugin would be "Meu plugin".

If the Wordpress is in en-XX language, the plugin name would be "My plugin".

Thanks!

How can I translate the name of plugin for other languages? For example:

When Wordpress is in pt-BR language, the plugin would be "Meu plugin".

If the Wordpress is in en-XX language, the plugin name would be "My plugin".

Thanks!

Share Improve this question asked Dec 3, 2019 at 13:08 Lucas VendraminiLucas Vendramini 3032 silver badges11 bronze badges 3
  • Did you had a look at the official WP docs? developer.wordpress/plugins/internationalization – Fabian Marz Commented Dec 3, 2019 at 13:12
  • Yes, @FabianMarz, in the docs is not clear how to translate Plugin Header fields Like plugin name and Description for example. It is automatic? – Lucas Vendramini Commented Dec 3, 2019 at 13:15
  • 2 @FabianMarz this is for the header comment, rather than strings in PHP – Tom J Nowell Commented Dec 3, 2019 at 13:22
Add a comment  | 

1 Answer 1

Reset to default 0

After searching a little bit more, I found that in the generation of the .pot file, the strings of plugin header already appear there. The tool I used to generate .pot file for my plugin was this command of wp-cli: https://developer.wordpress/cli/commands/i18n/make-pot/

I don't know if another tools to make plugin translation do that. The reason to use wp-cli instead of POEdit looks like .pot file generation is a premium feature of this kind of software ( version 1.6.11 tested in Windows 10).

So, basically with the .pot file (my-plugin-textdomain.pot) of your plugin and the translation of that (my-plugin-textdomain-language.po and my-plugin-textdomain-language.mo). You should load that using in your plugin file:


function my_plugin_init(){
   load_plugin_textdomain('my-plugin-text-domain', false, 'my-plugin-folder/languages');
}

add_action('init', 'my_plugin_init');

Reference: https://developer.wordpress/reference/functions/load_plugin_textdomain/

发布评论

评论列表(0)

  1. 暂无评论