3

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!

3

1 Answer 1

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.org/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.org/reference/functions/load_plugin_textdomain/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.