Making WordPress Plugin Multilingual

Making a wordPress plugin multilingual is not a problem at all. But beginners may face some issues with this. But don’t worry I have an easy and minimal solution for this issue. Today I am going to share an easy way to make a multilingual wordpress plugin. To do this we need an application name POEdit download and install it in computer. You can find the application here https://poedit.net/
Now we have to create a text domain in wordpress by which we can translate the sentence in different languages as we want. So for adding or creating a text domain we have to add the following function I the above of the main plugin file.


add_action( 'plugins_loaded', 'plugin_textdomain' );
function 'plugin_textdomain () {
  load_plugin_textdomain( ' plugin_textdomain ', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); 
}

Here two things to mention, First one is to create a languages directory in the plugin directory where all the languages file will be held and the second one is, we have to call the translated file in the name of the text domain that we have created (‘plugin_textdomain’).
Now if we want the text to be translated in our desired language then we have to write the text in the text domain format. For example:


echo __(‘print this in a different language’, ‘plugin_textdomain’);

Now it’s time for the desired translation to work. Open POEdit application and click on the menu ‘Translate WordPress theme or plugin’.

After doing that it will ask for the desired folder. Just select the plugin folder and the desired language and it will automatically get all the text domains. Now just click on the desired text and type the translated word in the desired language and save. Then you are done. Now if you change the wordpress language you can automatically see the translation for the word that you have created.

Just remember to save the desired language file in this format ‘plugintextdomain-languagename_languagecountrycode’. For example: plugin_textdomain-de_DE (for germany) in case of our sample example.
Now you can create as many as language files in different language as you want.
Hope this helped you a lot.

Saniul Ahsan

I picked PHP and JavaScript as a career start-up and developed a lot of applications using these. Like Management Application, Web Scrapping, Web API, E-Commerce Solutions, Finance Application etc. Outside of my professional life, I also do projects and code for reputation and my personal portfolio.