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

How can I translate the name of plugin for other languages? For example:When Wordpress is in pt-BR language, the plugin

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/

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744943953a4602498.html

相关推荐

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

    How can I translate the name of plugin for other languages? For example:When Wordpress is in pt-BR language, the plugin

    2天前
    50

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信