This article will show you how to translate a WordPress plugin to your local language of choice. We will look at the translator plugin called Loco Translate and the translation editor Poedit.
.mo and .po files in WordPress
Machine Object (MO) and Portable Object (PO) are translation management files in WordPress. PO files contain understandable human strings, which are compiled into binary MO files. As you can probably guess, we will be using .po files to edit the translation.
How to translate the plugin with Poedit?
For translating your plugin, you need:
- Poedit Editor installed on your computer. Here you can download OS X and Windows versions
- Flexible Invoices for WooCommerce plugin files on your computer
In this article, I will use the free version of Poedit Editor, and we will translate the Flexible Invoices for WooCommerce plugin.
You can find the PO and MO files in the Flexible Invoices plugin inside this path flexible-invoices-woocommerce > lang > flexible-invoices-woocommerce-pl_PL.po.
After installing, please open the editor and click File > Open. Please remember you can only edit .po files!
Now you see all the strings, and you can start with the translation. Click on each available string and write your translation into the Translation field.
Please notice that you have to add all the special characters from the source (original) text to the translation field. It will ensure the right translation by printing all possible variables.
When you’ve finished, you can save your new translation File as a new one. Please remember that you have to save this File with the plugin name flexible-invoices-woocommerce and the language-specific suffix at the end of the name.
For example, the Spanish translation file name should be flexible-invoices-woocommerce-es_ES. This is very important; otherwise, your translation will not work. Then choose Compile to MO. The files always come in pairs (.po and .mo). WordPress will interpret and pull data from .mo files.
The last step is adding translation files to your server. You can do that through FTP. Go to this path: wp-content > languages > plugins. Add both .mo and .po files into this folder.
Remember that language on your invoice will depend on the current language of the WordPress dashboard.
And that's it! The plugin is translated. Both your invoices and the interface should appear in the language you have chosen.
Translate plugin with Loco Translate
Loco Translate is a plugin to manage your translation directly from the WordPress dashboard. It is entirely free, so all you have to do is install it on your site. First, navigate to your Plugins. Then click the Add new button. And find Loco Translate on the bottom left of your Dashboard. Finally, install and activate the plugin.
Let's translate the Flexible Invoices for WooCommerce plugin with Loco Translate!
First, choose the plugin, list all active plugins, and click Flexible Invoices for WooCommerce. Secondly, click New Language and select your language from a dropdown. Please remember that you also have to choose this language from Settings > General to show translation on your site.
Then select the location of your translation and start translating the plugin. Now, click on every string one by one and translate it to the language of your choice. Save your work and check changes on your site.
Done, Flexible Invoices for WooCommerce is translated!
If you need to issue invoices in your WooCommerce store you may install this free plugin in your WordPress or download it from the WordPress repository.
Choose the best way to translate plugins in WordPress
As you can see, translating a WordPress plugin is not so complicated. There are many ways of translating. I showed you only two but, in my opinion, the easiest ones. You can translate other plugins and themes the same way I did.
If you want to translate just a few phrases inside a WordPress plugin, check the SayWhat plugin SayWhat plugin. It's a simple and quick way to translate strings of plugins and themes.
One more thing! If you want to test our plugins, create a DEMO account. Check out how to enhance your store with new plugins and their functionalities.
For more articles about plugins and e-commerce, see our blog.