Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Translate WordPress plugin header

How can I translate WordPress plug-in header?

I have translate all strings in my plug-in using:

  1. __() and _e() functions

  2. .po files

  3. Text Domain

  4. WordPress function to load language file

    load_plugin_textdomain('mnbaa-seo', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
    

I want to translate this section

<?php
/*
Plugin Name: Mnbaa SEO
Plugin URI: http://www.mnbaa.com
Description: WP blugin fom make SEO and Social SEO.
Author: Mnbaa CO
Author URI: http://www.mnbaa.com
Version: 1.0
Text Domian:mnbaa-seo
Domain Path: /languages/
*/
?>
like image 562
Amr Shabory Avatar asked Apr 15 '26 13:04

Amr Shabory


1 Answers

You have to use WordPress' i18n tools to get the plugin's description translatable. i18n tools' makepot.php lets you auto-generate a .pot file, which then can be used to create the .mo/.po pair (with the free PoEdit for example).

The easiest way would be:

  1. Download the zip from https://github.com/wp-mirrors/wp-i18n-tools.
  2. Extract its content into the wp-includes folder.
  3. Command line one-liner from within WP root: $ php wp-includes/makepot.php wp-plugin wp-content/plugins/MYPLUGIN/ wp-content/plugins/MYPLUGIN/MYLANGFOLDER/MYPLUGIN.pot
  4. Then you take this resulting .pot file as source for PoEdit.
  5. Finally ensure to name the .mo/.po like your plugin plus language code, for example: MYPLUGIN-de_DE.mo/MYPLUGIN-de_DE.po.

More (but not quite up-to-date) info can be found at WPO: https://codex.wordpress.org/I18n_for_WordPress_Developers#Translating_Plugins_and_Themes

I wonder if maybe PoEdit Pro can do that without us calling on the command line... Maybe someone who knows can drop a comment below.

like image 150
leymannx Avatar answered Apr 18 '26 10:04

leymannx



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!