Podcast Episode

399 – Translating a WordPress Plugin

Announcements

Is there a plugin for that?

With more than 50,000 plugins in the WordPress repository, it’s hard to find the perfect one. Each week, I will highlight an interesting plugin form the repository.

For more great plugins, download my 50 Most Useful Plugins eBook.

Nifty Desk is the easiest to use Help Desk & Support Ticket plugin. Create a support help desk quickly and easily with Nifty Desk

Translating a WordPress Plugin

How Translations Work

Plugins and themes will include a .pot file which is like a directory of translations available for all the code. They look like this:


#: includes/admin/class-wc-subscriptions-admin.php:121
msgid "Simple Subscription"
msgstr ""

That code literally means “Translate the string ‘Simple Subscription’ found in ‘class-wc-subscriptions-admin.php’ on line 121”

Translations in WordPress work using the getttext translation system in PHP. Here’s how translating works:

  1. You open up a .pot file and create a new translation based off of the strings in that file.
  2. You now have a .po file that looks like this woocommerce-subscriptions-es_ES.po which would be for Español (Spain).
  3. You make your translations in that .po file, and when you’re done, you compile it into a .mo file, which is what WordPress reads and uses.
  4. The .mo files can live in the WordPress languages folder, or in the plugin or themes languages folder.

We have a great doc on how to translate things with this WooCommerce Localization guide.

Thank You!

Thank you to those who use my affiliate links. As you know I make a small commission when someone uses my link and I want to say thank you to the following people. For all my recommended resources, go to my Resources Page

Full Transcript

Business Transcription is provided by GMR Transcription.

On today’s episode, we are going to talk about how to translate WordPress plugins right here on your website engineer podcast, episode No. 399.

Hello. And welcome to another episode of your website engineer podcast. My name is Dustin Hartzler and today we’re gonna be talking about WordPress, obviously. That’s what the podcast is all about. But we’re gonna be talking about how to translate plugins. And this may or may not be useful information, but I find that a lot of times we need to translate, or we need to change some words or change some text in a plugin or inside of WordPress itself or our theme or whatever. And this is an episode that’s going to kind of highlight and point out some of those ways that we can do that.

And so, we’re gonna talk about that in just a minute or so, but I do have an announcement and a plugin to share. The first announcement is that the WordPress 4.9.8 Beta 1 is now out and available. So, if you are interested in starting to test this latest version you can go on over to development site and you can install the Beta plugin. And then with the Beta plugin installed and activated you can go ahead and download the latest nightly release, it’s called. And then you can see what’s all in there in the newest and latest and greatest features from WordPress.

And so that’s the latest thing that’s happening in WordPress right now. There’s been it looks like 21 bugs or so that have been fixed and nine enhancements and two blessed tasks. So, that means that they are continuing to work on just cleaning up some of the things and getting all of this stuff fixed before we get to the release candidate stage. So, we’ll see WordPress 4.9.8 for a few weeks and then we’ll have that released and then hopefully the next thing we see is WordPress 5.0 with the beloved Gutenberg editor that is coming. So, that is that.

The other announcement is that right now as this podcast releases I’m in Philadelphia for Podcast Movement. And so, I am there hanging out with a bunch of podcasters and just sharing about how WordPress.com is a great hosting platform for both podcasters or bloggers or even storeowners. That’s kinda the main message that we’re sending there at the Podcast Movement. So, that is why there are not a lot of announcements or there could be some more things happening, but I’m recording this a week early. So, that is that.

Moving right along to the “Is there a plugin for that?” section, there’s one called Nifty Desk. And that’s one that I found. I was searching for “nifty plugins” and this one came up because the name is Nifty Desk. But this is a support desk plugin for WordPress. Their plugin states that, “It’s the most comprehensive and feature-rich support desk plugin for WordPress by far.”

So, I don’t know if that’s the case, but if you are looking for some sort of helpdesk support within your WordPress site, then this is one that I would check out. You can submit tickets, you can receive email notifications, you can set priorities, internal notes, all kinds of things. They do have a premium version as well if you’re looking for that. And then coming soon is a mobile app. And so, if that is something you’re looking for to implement on your WordPress site, I would recommend checking out Nifty Desk in the WordPress repository or you can find a link to it in the show notes for episode No. 399.

All right. Today we’re gonna be talking about translating. And this really comes to the point – I came up with this idea or wanted to share this idea because, 1.) I don’t think I’ve ever talked about it because I just barely understand the concept myself and I’ve just recently learned about it and how to figure out how this all works. And it’s mainly because we have a ton of customers that come using WooCommerce and they want to set up their site in a different language. Maybe English isn’t their native language, maybe they’re in Spain and they want Spanish as their main language. And then they buy these premium plugins and all of a sudden, the premium plugins don’t have the correct language.

So, most of the website is in Spanish, but then all the premium plugins or the plugins that don’t support localization of the text, then those will all be displayed incorrectly, or they’ll be in the native language that they’ve been programed. Which is most of the time it’s in all WordPress plugins it’s mostly English. And so, I wanted to go through today just kind of talking through the process of setting up and changing the text and the way that text is displayed inside of your WordPress site.

So, we’ll talk about WooCommerce, but you can think about any plugin on the WordPress repository. Most of them, if they are done by a reputable company or have a large team behind them come localization-ready out of the box and that’s all that’s needed is the translated file for your language. So, for example, WooCommerce, I was looking at the iTheme security, that’s one that’s out there. You can go to translate.WordPress.org/product/wp-plugin/ and then the slug of the plugin. So, [inaudible] [00:04:30] or Better WP Security or whatever plugin you’d like to see, and it will show all of the translation versions of WordPress.

And so, for example, I’m looking at the Better WP Security plugin. And this one is translated 100 percent into English. English Canada, actually. But it also is 95 percent in Persian. It is 90 percent in German. German formal is at 90 percent as well. English UK is at 75 percent. Spain, parts of it is – the development is at 100 percent. The stable is at 100 percent. And so, it just goes through and it shows you the percentages. If I wanted to look at Hebrew, it’s only at 4 percent. So, only 4 percent of the strings inside of the Better WP Security have been translated into Hebrew.

And so, you [inaudible] look to see if your language is there. Like, if I look at the WooCommerce one, the WooCommerce one has a ton more languages. And it’s English. I guess three versions of English: Australia English, Canada English, New Zealand English. Spanish from Spain. Croatia, Norwegian, Polish, Portuguese. Those are all translated to 100 percent. Then Chinese is at 99 percent. Danish is at 100 percent. Japanese, Turkish, French, Italian, parts of that is at 100 percent. Italian, Arabic, Dutch.

You can see there’s a lot of – and I’ll put a link in the share notes, so you can just take a look and see what this looks like. But you can see there’s a lot of plugins that have already been translated into the native language. So, if the plugin is already translated into your language, this is gonna be a very simple exercise. If it’s not, then we’ll talk about the ways that you can translate the plugin and how you can attribute back and help out other people that are using the plugin in those natural languages.

First things first though. First, we need to set WordPress in your language. So, you need to tell WordPress what your language should run. And you can do this when you’re setting up WordPress for the very first time or if you didn’t do that in that step, you can go to your dashboard, you can go to settings and to general and you can change the site language. And then once this is done, the shop will display, or your website will display in the local if the language file exists.

So, if you change it to Spanish – let’s say you wanna change it to Spain as your site language, then what happens is you will – all the plugins that have the translation files available for Spain will automatically download and they will start displaying those pieces of information in Spanish. Whether that be the dashboard side or the frontend side of your website. If it doesn’t happen, so if you are seeing some things in the backend that are still in English or some of the – like maybe the My Accounts page on WooCommerce, maybe some of those strings aren’t translated properly, then that’s when we need to start creating and working through and getting the language files correct to set up for your country.

We’re gonna continue to talk about WooCommerce. And this is just mainly because WooCommerce is one that I deal with every day and it’s one that’s freely available on the WordPress repository. This is how all plugins on the repository work. If they are a premium plugin, you can also do a lot of these steps to translate the plugin’s text, but let’s go ahead and just talk through the process of translating or getting the files translated from the online repositories.

So, the whole translation process is managed over at translate.WordPress.org. And it has the stable versions and the development versions. And that’s what we were talking about earlier. What countries or what languages are already translated to 100 percent. Once you install a plugin from the WordPress repository, it’s going to first look for 100 percent complete translation in your language and automatically download it.

So, if your language is 100 percent translated, it will automatically download it. If it’s not 100 percent complete, then you can download it manually, or you can contribute to it right there on translate.WordPress.org to get it to 100 percent so then all users will benefit and then it will automatically download for all users that have selected that language.

So, that’s kinda the first piece of it. If you are trying to translate into a language that’s not 100 percent complete translated yet, then what you wanna do is you’ll go to translate.WordPress.org and you will go to the project and you can search – within that page you can search for WooCommerce or you can type whatever plugin that you’re looking for. And then you can click on the title.

You’ll click on the title, so maybe German, or English, or Croatian or whatever and click on the heading under subproject and you can download a stable version. And you can scroll to the bottom of that page and you can – you export a .mo file for use on your site. You can rename this to WooCommerce and then your language and then you can upload that to WooCommerce and that’s gonna start working. That’s all you need to do.

Now, if you need to do some custom translations, then what you wanna do is WooCommerce includes a language file. It’s called a .pot file that contains all of the English text. And you can find more about this. It’s always in the WooCommerce/i18n, which stands for internationalization, slash languages. And a lot of plugins have this. Or they’re in the WooCommerce – or in the plugin name/languages file. If your country’s language isn’t 100 percent translated, then you’ll have to go and download what’s already available.

So, you can head on over to translate.WordPress.org and then you can search for the plugin that you’re looking for. Again, that plugin has to be on the WordPress repository. And you search for that, you find it, then you click on the title to be taken to the section for that language. So, whether that be German or Polish or Russian, you pick the language. And then under the heading “Set subproject”, you set that to “view” and download a stable version. You’ll scroll to the bottom and you’ll look for export options and you can export a .mo file for use on your site.

And then you can rename this file. You’ll have to rename this to WooCommerce dash and then your language. And there’s a special nomenclature that there’s linked in this document that you can name it correctly. So, for example, if you’re doing Great Britain English, it would be WooCommerce-en_gb. And again, there’s a link to know exactly which language file to put in there. And then you will take this .mo file and you will put it into wp-content/languages/WooCommerce and put that file right in there. And then it’s going to start translated – like all your texts will be translated based on whatever percentage of texts has been translated from the translate.WordPress.org site.

You might be saying, “Okay, Dustin. That’s fine. We’ve got that set up, but I wanna translate everything. I wanna make sure that there’s all the text or maybe there’s a very specific piece of text that I wanna translate into a different language.” And so, we get this a lot. Like, “How do I change the add to cart button? I wanted it to say something else.” Or, “I wanna change this link that’s already been generated by WooCommerce or generated by a plugin. I wanna change that to a different text.”

What we recommend is a plugin called Loco Translate. It’s a free plugin. You can download it from the WordPress repository. There’s a link in the show notes for it. And you can add it to your site. And then once it’s created, you’ll have a new section inside of your WordPress dashboard called Loco Translate. You’ll go to the plugin section and you’ll select WooCommerce or whichever plugin you’re trying to translate and then you can add a new language using the new language link. You choose the language, you add it to your list or add the ISO code, so French or US or whatever, and then you select the language folder to add the translation files to and click “Start translating”.

Now, Loco Translate offers three different locations for you to create your translation and the best choice is custom. If you’re looking to have your own custom translating, you should avoid the author location since that’s inside the plugin and would be overwritten on updates. There’s also a system location which would be overwritten by translations from translate.WordPress.org. So, go ahead and choose the custom location and you can save when finished.

And then what that does is that brings up a file and it shows all of the text on the left which is in the English text and then on the right it’s all of the text that you wanna translate to a different language. And so, whether that is you wanna change the word “Add to cart” and you wanna add – make it in Spanish or if you wanna just say something else if you’re still in English, you can go ahead, and you can have this as a custom translation tool. Even if you’re using English and you wanna change the text, this is the recommendation. You’d go and use Loco Translate and you can use that to just change the text across your site.

If a plugin gets updated and maybe new strings are available, you can use the sync button to find any new strings and you can start translating those as well. I’d recommend Loco Translate for either just making one-off changes, you wanna change this, that, or the other text to something that just makes a little bit more sense for your audience. Or you can use Loco Translate and translate your entire site. It’s a little bit more tedious to do but is definitely possible.

An advanced alternative is called PO Edit. And this is basically it will use a POT file, which just stands for a PO template file. And these are included with a lot of plugins. So, with WooCommerce there’s a POT file located in the languages file. And so, you would go to PO Edit, this is a software product or an app that you install on your computer. And then you will open up a .pot file and it will show you some details about the plugin and whatnot.

You can enter your name and details so other translators know who you are and then you can click, “Okay.” And it will generate, and it’ll go through and it’ll pull in all of those strings that we saw on Loco Translate, it’ll show them all here inside of the PO Edit program. You can start translating the strings and once you do it you can save. A .mo file is generated automatically and then that .mo file is what you add to your theme files itself.

Then once you save that .mo file, you can upload it to your server and save it so that it will start working on your website. Now, where would you save it? There are a few different places where you could save these files. So, you’ll need manual access to your server. So, an FTP client would be perfect for this. And you can put these .mo files in several different places.

So, you have to add this .mo file to your server. And using an FTP client would be a perfect place for this. So, there are three different places that you can add this. A custom location which is gonna be under wp-content/languages slash whatever the plugin name slash the plugin name .mo file. So, that’s the first place. You can put it in your own location under languages and then plugin name.

The default one, where WooCommerce, if it downloads it from translate.WordPress.org, is going to put it in wp-content/languages/plugins and then the plugin name. And then the last place that it could go is in wp-content/plugins/plugin name/languages and then put the .mo file in there. And the lower that you go, so that last one that I just said, that one would get overwritten if there was an update to the plugin. So, I would recommend just putting it in that top one inside the wp-content/languages and then create a folder that’s the name of the plugin and then put the .mo file inside of there.

And that’s how it works. It’s very much like a child theme. Like the child theme loads on the parent theme first and then the child theme second to get all of those visualizations from the child theme. It’s very similar to this. Like depending on where it gets the top-level translation first. If nothing exists there, it will go down to the bottom one and the one below and the one below it.

So, even if you have a custom one and you’ve pulled the one down from translate.org and the plugin itself is translated in – the language file is included inside the plugin as well, your custom one, which is at the top of this hierarchy, is going to be the one that’s used. And so that’s how that all works.

There’s another plugin out there called Say What? And this can assist if you want to just translate or change a few words without editing WordPress’s theme .po file, requires no custom code, and it basically looks for a string. So, you pick the string that you want to translate, maybe “Add to cart”, and then you’ll say the text domain. So, you’ll say that’s a WooCommerce text domain and then you’ll say the text that you wanna display. So, maybe “Put in basket”. You can say that and that’s how you could translate the text. So, that’s a lot easier, it’s a lot simpler of an option, but Say What? is the plugin that you can do that.

I will admit, translating plugins, translating WooCommerce, translating premium plugins, it’s not the easiest thing in the world. If you have purchased a premium plugin, especially one from woocommerce.com or maybe easy digital downloads, a lot of times those do not come with additional language files.

And so, what I recommend there if you do spend the time and translate those files, send over a PO file or a POT file over to the developers. I’m sure they would gladly add those to their repository and send those out with the latest versions. It’s just so hard to translate all of the files all the time to all of the languages. That just makes it real cumbersome for plugin authors to do that. But if you are willing to step out and send that information back to them, I know that they would greatly appreciate it.

Have you ever tried to do a localization or translate a plugin? If so, let me know in the comments for episode No. 399. If not, well look forward to episode No. 400 which is next week, and we’ll talk again then. Take care and have a great day. Bye-bye.

    • dljordaneku Reply

      I downloaded the NiftyDesk to test and see if it would work for me. The home page is a bit misleading as the features they list are not a part of the free version.

      Jul 26, 2018
      • Dustin Hartzler Reply

        Ah, bummer! Sorry for leading you astray.

        Jul 27, 2018

Leave a Reply