|
You may know that over 835 million websites use WordPress today. But how can you ensure your plugin or theme can be used as widely as possible within the ecosystem?
Surprisingly enough, less than half of all WordPress sites have their locale set to English. If you don’t have translations set up already, that means more than 50% of your potential customers probably can’t work with your product in the language they best understand.
One of the best ways to open up your product to the world is to create high-quality translations of all user-facing text.
The problem is that translation takes a lot of time — the more text you have throughout your product, the more strings to translate. Translation also requires proficiency in different languages, knowledge of how to manage MO and PO files, and overall, a whole lot of effort.
My name is Diego Imbriani, and I’ve been a plugin developer since 2011. I used to sell my plugins through my company GreenTreeLabs (all sold out now!).My products are currently active on ~70,000 websites worldwide.
Thankfully, I found a way to alleviate the whole translation process and simplify translating plugins and themes. Below, I’ll walk you through the process step-by-step, showing you how you can use the script I created to automatically translate your WordPress plugins or themes.
Why You Should Translate Your WordPress Plugin
I recently wanted to add an Italian translation to one of my plugins: Final Tiles Gallery for WordPress, so I opened the plugin’s PO file, which contains all translatable strings, and I started translating my plugin line by line.
The Final Tiles Gallery PO file has about 350 entries, and translating them all would require about 2 hours. Honestly, I didn’t find this job very appealing. As I was digging through the translations, I wondered if there was a way to automatically translate my PO file…
I decided to experiment a little with the Google Translate API and managed to code a script to accomplish my idea.
I must admit I’d never thought about translating my plugins before. I’m Italian, but I’ve always used programs and operating systems in English. It would feel “weird” to use any kind of user interface that’s not in English. But, maybe that’s just me. 🙂 There are many countries and nations that aren’t as proficient in English.
WordPress is used by millions of people of different backgrounds, languages, and cultures. We simply can’t ignore the need to translate our plugins and themes to make them accessible to as many users as possible.
WordPress is used by millions of people of different backgrounds, languages, and cultures. We simply can’t ignore the need to translate our plugins and themes to make them accessible to as many users as possible.
I sell my plugins using Freemius, which has a nifty dashboard with extremely useful analytics and stats. A few days ago, I had a look at the “Top 10 Languages” table that you find in their Developer Dashboard. Although I know many sites with Final Tiles Gallery are not in English, I was surprised to find that out of a sample of about 40,000 installations, only around 40% of websites are in English!
Here’s the overview:
As you can see, French, German, and Russian users make up a large percentage of the total — 32,5%.
Benefits of Translating a Plugin or Theme
For WordPress plugin or theme businesses, translating our products is also a marketing opportunity for many reasons:
Larger audience
Not all WordPress users are willing to install a plugin that doesn’t have a translation in their language. That could be for many reasons, but mainly because they may not understand English.
In other cases, users might understand English, but simply feel more comfortable using their own language. So, given the choice between two similar plugins, those customers would pick the one in their language, even if the other plugin offered better quality.
People may prefer languages other than English due to cultural reasons, too. As an example, for historical reasons, especially the older generation of French people don’t like to use English. Moreover, less than 30% of French people say they actually speak the language with confidence, according to some recent surveys.
So, if your product isn’t translated into French, you may immediately lose over 60% of the French WordPress market share. If there’s a French alternative to your product, you probably lose them all, or at least the vast majority. Similar analyses are relevant to many Asian countries, like Japan, that are not yet “Americanized”.
WordPress.org SEO
Vova Feldman, Freemius CEO, has written a bit about the benefits of translation for SEO on the WordPress.org repository. I can’t emphasize these benefits enough.
The fact is the search algorithm on the repo is highly sensitive to the use of different languages in your readme.txt. Focusing your translation efforts on your product strings and your readme.txt can compound your marketing reach on the repo. While most users are searching in English, it’s clear, based on the locale stats from WordPress.org mentioned above, that many users don’t search in English. Therefore, they have limited access to many of the plugins and themes available to those who understand English.
The algorithm shows different results based on the locale of a given WordPress installation. Translating your product overcomes this barrier to getting exposure to users you’d normally never be able to reach.
Vova put it very well when he said, “Bottom line – translations are now more important than ever!” – and it’s still true more than a year on.
Reputation
Translating your plugin or theme has positive psychological implications for your customers. A plugin or theme that offers translations in your customers’ own language can be perceived as a higher-quality product. It means the developer invested time into more than just the technical aspects of the plugin and the customers may recognize this value.
A plugin or a theme that offers a translation in your own language can be perceived as a high-quality product. It means the developer took care to spend time on more than just technical issues.
Contributors
Adding translations to your plugin or theme can create a knock-on effect of voluntary translators on the WordPress.org repository if you offer a free plugin or theme. Even a plugin that’s only translated into a few languages is perceived as being much more popular than a plugin with no translations at all, so volunteers may be more inclined to contribute.
So, now that you understand the benefits of translating your product, the next question is: How many languages should you support?
Choosing Supported Languages
There’s no limit to how many languages you can support. But, you should consider a few things before diving into translating your plugin or theme into all of them.
The problem is this: if you translate every language using Google Translate, there will inevitably be incorrect translations. This may result in negative user feedback pointing out the mistakes.
To resolve this problem, I suggest starting with the most popular languages. This type of data can be obtained from three places:
- Freemius Developer Dashboard
- WordPress.org stats page (which shows the most popular WordPress locales)
- Google Analytics stats for your product’s website
Grab a free copy of our Cheat Sheet for
Selling Plugins and Themes
A growth roadmap with concise, actionable tips for every milestone of WordPress product development.
Wherever the numbers point, you can choose the languages that have the largest audiences. If you offer a few translations to those audiences first, you can ask some of your customers or colleagues to review the translations before you release them publicly. This way, you won’t be overwhelmed with customer feedback reporting minor translation issues.
Fiverr has numerous professionals who can help review your translations. You can further minimize your support load by adding a notification in your plugin or theme’s WP Admin settings to inform users to suggest translation updates on the WordPress.org repository instead of submitting a support ticket.
Following this step-by-step process for each language is a logical way to achieve high-quality translations and prevent your support queue from overflowing with tons of small tickets.
Using the Google Translate API to Translate Your Plugin/Theme
Google Cloud provides an API so that you can use Translate as a service.
Google Translate API Pricing
Version 3 of the API is free for up to 500,000 characters per month, and $20 per million characters if you exceed the quota. You can read the pricing details here:
A Quick Side Note – Internationalized
All plugins must be internationalized before being localized. A great place to start is the WordPress.org guide I18n for WordPress Developers that explains the steps. Once you’ve created your .pot/.po files, you can proceed on the scripting process below.
All plugins must be internationalized before being localized. A great place to start is the WordPress.org guide I18n for WordPress Developers that explains the steps.
Let’s Script!
Before we can run the script we need to create a new project in Google Cloud console. If you need help with this task, check this guide or follow these steps:
- Go to https://console.developers.google.com and login.
- Click “No organization” or select your preferred organization (we assume you don’t have one):
3. Click “New project”:
4. Enter a project name and click “Create”:
5. Now you should be redirected to the Console dashboard. Click “Enable APIs and services”:
6. Search for the “Cloud Translation API”:
7. Click “Enable”:
Now that we have a project, we need to set up a service account to authorize our requests to Google APIs. You can follow steps 1 and 2 on this guide from the Google Cloud platform otherwise follow these steps:
- Go to “Service accounts” section from the main menu: “IAM & Admin”:
2. Click on “Create service account”:
3. Enter a name and a description for the service account and click “Create”:
4. Click “Continue” to skip role selection as we don’t need it:
5. Now click “Create key” and then click “Create”, make sure you selected the JSON format:
6. After you create the key, the browser will download it automatically. Remember the folder where you’re going to save the file as we’ll need it later.
Now it’s all ready to go but before running the script be sure you have set the GOOGLE_APPLICATION_CREDENTIALS environment variable as described in the guide:
Example: Linux or macOS
Replace [PATH] with the file path of the JSON file that contains your service account key.
export GOOGLE_APPLICATION_CREDENTIALS="[PATH]"
For example:
export GOOGLE_APPLICATION_CREDENTIALS="/home/user/Downloads/service-account-file.json"
Example: Windows:
Replace [PATH] with the file path of the JSON file that contains your service account key, and [FILE_NAME] with the filename.
With PowerShell:
$env:GOOGLE_APPLICATION_CREDENTIALS="[PATH]"
For example:
$env:GOOGLE_APPLICATION_CREDENTIALS="C:\Users\username\Downloads\[FILE_NAME].json"
With command prompt:
set GOOGLE_APPLICATION_CREDENTIALS=[PATH]
Now that we are done with the boring stuff, we can start translating!
- Clone the repository from https://github.com/GreenTreeLabs/po-gtranslator
- Open up your command line and run the following command:
- Git clone https://github.com/GreenTreeLabs/po-gtranslator.git
- If you don’t have git installed you can download it here.
- Enter the directory po-translator:
cd po-gtranslator
- Install the dependencies:
npm install
- In case you don’t have the npm utility be sure to install Node.js from here.
- Run the script with all the needed parameters:
node po-gtranslator.js --project_id=final-tiles-gallery --po_source=it.po --po_dest=it_IT.po --mo=it.mo --lang=it
Let’s have a look at each parameter:
--project_id
: ID of your Google project, you can get it from the Google Cloud Console
--po_source
: path of the empty PO file that you want to translate
--po_dest
: path of the PO file with the translations
--mo
: path of the MO file
--lang
: code of the language you want to translate to
Note that the source PO file will be kept untranslated and it can be used to generate as many languages as you need. The PO file you need to add to your plugin or theme is the one you pass as –po_dest, which is unique for each language.
Thanks for scripting with me!
It’s been a fun learning experience for me to figure this process out.
If you’re thinking about other steps to make your plugin appealing to broader audiences worldwide, consider multi-currency support and pricing.
Check out our guide to learn why offering multiple currencies is important and how Freemius can help with implementation.
The worst idea to give to a dev as any Google translations will be rejected by most of WordPress.org GTEs or PTEs. It’s just a waste of time and money.
If you need to get your plugins/themes translated you should better ask and invest in dedicated companies, like WP-Translations ;)
Thanks for your feedback. I actually have published my translations and none has been rejected. If we want to discuss about the quality of an automatic translation VS a human one, clearly no doubt the latter wins but this is clearly stated in my article ;)
I think that there are two different cases :
- When you are the developer of a plugin, there is no review from WP teams to check your translations, you can put whatever you want.
- When you want to contribute for a plugins translation, you can submit it, but WP team will check it and take a moment before validate it.
I've tested both, that's why I say that.
Thank you Diego for sharing this article. Nicely explained with detail steps for translation endeavors.
Diego, such a detailed article. Till date, I haven't think about the translations of the themes and plug-ins. Thanks, Benard for sharing us about WP-Translations.
Hi Diego,
Thanks for sharing nice post to translate WordPress plugins with Google translate. These tips will help me to translate themes and plugins. I am sharing some valuable tips to improve website speed in 2019: https://www.techmagnate.com/blog/how-improve-web-page-speed/
Hey Diego,
How do you handle translations if you're using Freemius to generate a free version AND a premium version of your plugin? The .POT file for the free version will contain references to text that does not exist, and the line numbers will be wrong.
Hey Chris, sorry for the very late response. The free version contains also the strings contained the premium version so not really the best solution, however you can run the script twice, one for the free version and another for the premium one.
Hey Diego,
It's really great IDEA. I've been struggling for Translation issue a lot. Now, it seems you've made my job easier.
Best Regards
Liton Arefin
How do you handle translations if you’re using Freemius to generate a free version AND a premium version of your plugin?
You can run the script twice, one for the free version and another for the premium one.
Thank you i translated my https://wordpress.org/plugins/cf7-styler/ Plugin with free and well supported plugin:
https://wordpress.org/plugins/automatic-translator-addon-for-loco-translate/
My questions is how to upload the mo. / .po files into WP translation area so others can contribute too?
Only translate the plugin and add mo. / .po files to the plugin folder would not do the trick.
@Mcurly
According to https://make.wordpress.org/meta/handbook/documentation/translations/ WP’s system imported po/mo files once, but not repeatedly.
So translations contributors would need to submit their translations to you, the plugin author, directly for merging into your repo.
Thanks a bunch for this. I needed to translate a theme, and really didn't want to do it all by hand. This is a fantastic time saver. all that will be left when the file finishes processing will be to check and trim, and that would be it.
Fantastic guide!
Thank you :)
Hello Diego,
This is a great tutorial! I completed all the steps you described succesfully and I triple-checked them. When I run the script, it throws the error message below at me. The .json file is definitely in the right spot; I also tried moving it to an other folder and even another disk, but that didn't solve the issue.
Do you have any idea of what I'm doing wrong and how to solve that?
Thank you,
Harold
C:\Users\Harold Kip\po-gtranslator>node po-gtranslator.js --project_id=MY-PROJECT-ID --po_source=D:\Downloads\en_EN.po --po_dest=D:\Downloads\nl_NL.po --mo=D:\Downloads\en_EN.mo --lang=nl
(node:3480) UnhandledPromiseRejectionWarning: Error: The file at "C:\Users\Harold Kip\po-gtranslator\MY-PO-TRANSLATE-FILE.json" does not exist, or it is not a file. ENOENT: no such file or directory, lstat 'C:\Users\Harold Kip\po-gtranslator\"C:'
at Object.realpathSync (fs.js:1539:7)
at GoogleAuth._getApplicationCredentialsFromFilePath (C:\Users\Harold Kip\po-gtranslator\node_modules\google-auth-library\build\src\auth\googleauth.js:250:27)
at GoogleAuth._tryGetApplicationCredentialsFromEnvironmentVariable (C:\Users\Harold Kip\po-gtranslator\node_modules\google-auth-library\build\src\auth\googleauth.js:192:25)
at GoogleAuth.getApplicationDefaultAsync (C:\Users\Harold Kip\po-gtranslator\node_modules\google-auth-library\build\src\auth\googleauth.js:130:33)
at GoogleAuth.getClient (C:\Users\Harold Kip\po-gtranslator\node_modules\google-auth-library\build\src\auth\googleauth.js:502:28)
at GoogleAuth.authorizeRequest (C:\Users\Harold Kip\po-gtranslator\node_modules\google-auth-library\build\src\auth\googleauth.js:543:35)
at Translate.makeAuthenticatedRequest (C:\Users\Harold Kip\po-gtranslator\node_modules\@google-cloud\common\build\src\util.js:377:28)
at Translate.request_ (C:\Users\Harold Kip\po-gtranslator\node_modules\@google-cloud\common\build\src\service.js:129:18)
at Translate.request (C:\Users\Harold Kip\po-gtranslator\node_modules\@google-cloud\common\build\src\service.js:140:36)
at Translate.request (C:\Users\Harold Kip\po-gtranslator\node_modules\@google-cloud\translate\build\src\v2\index.js:439:19)
(node:3480) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:3480) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Nevermind. I found another solution.
Could you please name it?
Thanks in advance.
Is there a place where I can translate a plugin into my native language in exchange for translation of my plugin?
Thanks for sharing this!
Admittedly I got started on this, but somehow learned PoEdit Pro also does this, so coughed up some money to buy it and saved myself a bit of time.
Thanks for sharing PoEdit Pro. Were the translations accepted at the WordPress plugin directory?
Hi Anindya, I paid for the version of PoEdit that gets the automatic translations via Microsoft. I’d guess about 1/4 of the translations should be fixed: they either don’t use WP jargon correctly (eg posts) or simply don’t make much sense.
Regards to accepting them to the WP plugin directory’s translations: I don’t know how to submit a .po file to WordPress.org’s GlotPress. Like I commented earlier, as I understand it, the WP.org team only imported a plugin’s .po files once when they started GlotPress, but haven’t imported them since.
So I include my .po files in my plugin, so users of those languages use them just fine, but my plugin doesn’t appear as translated on WP.org.
Hi Michael,
Thanks for the reply. In order to achieve the benefits of SEO at the WP plugin directory, we need to submit the translation at GlotPress. It'll appear as translated if they accept it.
To submit a .po file to WordPress.org’s GlotPress please log in and go to this link: https://translate.wordpress.org/projects/wp-plugins/hello-dolly/
Just replace 'hello-dolly' with your plugin's Text Domain.
Then click the relevant language's Development, Development Readme, Stable and Stable Readme link and click 'Import Translations' (at the bottom of the next page).
Please share your experience, if you submit the translations.
oh nice! I did not see that "import" (or export) option at the bottom of the page. Thanks Anindya!
I'll try submitting them but given how slow manual translations have taken to get accepted to GlotPress (for my plugin, many of the translations have sat unapproved for years), I don't have great expectations. But we'll see!