How to Translate WordPress Plugin in Any Language

how to translate wordpress plugin into any language

WordPress translation has become a hot topic recently. More and more internet users are either building sites with the software or visiting WordPress sites. This is why it makes sense to generate more content and tools in languages other than the platform’s default language—English. Whether you’re a WordPress developer or website owner, this may be the ideal time to learn how to translate a WordPress plugin into any language.

Content localization is a powerful strategy that profitable businesses use to appeal to their target audience and increase their reach. As an integral part of content localization, translating your WordPress site requires you to translate both plugin-generated text and user-generated content.

Some major plugin developers already do this for you as part of their plugin internationalization strategy. But what if a plugin you want to use is not translation-ready or you’re building a new plugin? Not to worry!

In this article, we’ll show you everything you need to know about how to translate a WordPress plugin. We’ll talk about how the process works, why you should do it, and then translate a plugin using TranslatePress.

TranslatePress Multilingual

TranslatePress is the easiest way to translate your WordPress site. It's fast, won't slow down your website, works with ANY theme or plugin and it's SEO friendly.

Get the plugin

Or download FREE version

Why Translate a WordPress Plugin

The WordPress space is a large worldwide community that consists of a diverse group of developers, enthusiasts, and site visitors. As this community continues to grow, more people would prefer to see websites and use WordPress tools in their language.

Granted, the WordPress software is now available in multiple languages. But you’ll still need to do some work to create multilingual websites that non-native English speakers can interact with in their languages.

Part of this work involves learning how to translate a WordPress plugin or a WordPress theme. Here are 3 common scenarios when WordPress plugin translation becomes necessary:

  • Translating a WordPress plugin you developed. As a WordPress developer, internationalizing your product is a sure way to get more downloads and reach a wider audience. Translation has also become a best practice that can help you look more credible compared with the competition. Taking this extra step after building a great plugin can save your non-English users a lot of time and effort and help them get the best of it.
  • Helping a WordPress developer translate their plugin. Similarly, you may have just found a plugin you’d like to add to your site. But it isn’t available in your native language. If you’re bilingual, the plugin developer will appreciate getting help with an accurate translation. WordPress and a lot of the major plugin developers encourage this. For example, WooCommerce asks community members to contribute to their translation process. Such contributions are submitted to the Translating WordPress site where they are managed by expert teams.
  • Translating a plugin for your site. This use case involves translating a WordPress plugin strictly for use for your website. It’s arguably the most common scenario. WordPress site owners and administrators translate a plugin’s text as relating to their website. In most cases, the changes reflect immediately.

In this article, we’ll focus mostly on the third use case as it’s often the most relevant for WordPress users looking to create a multilingual website.

How to Prepare a WordPress Plugin for Translation

Before showing you how to translate a WordPress plugin, we need to first ensure that the plugin is translation-ready. The process of translating a plugin is a little different from translating the static text on your WordPress site.

Just like WordPress themes, plugins contain translatable text strings within their code. These text strings can appear both on your site’s front and back end. Translating this text in a plugin’s code can easily be done using the GNU gettext framework.

Let’s take a closer look at this process.

How WordPress Plugin Translation Works

As mentioned earlier, WordPress relies on the GNU gettext localization framework for plugin and theme translation. This framework is part of a much larger GNU Translation Project that allows software programmers, translators, and users to create multilingual tools and documentation.

To make text strings within a plugin’s code translatable, developers add a gettext or localization function to the code. So, a plugin is only translation-ready if the text strings in its code are wrapped in a gettext localization function.

Let’s take a look at these 2 examples of simple code:

<p>Plugin activated</p>
<p><?php _e( 'Plugin activated' ); ?></p>

The first line of code above is a hard-coded text that simply tells WordPress to display the ‘Plugin activated’ text. This takes no account of the language and will always be displayed as ‘Plugin activated’ even if you change the site language to Spanish.

On the other hand, the second line of code adds a gettext function to the ‘Plugin activated’ message. This means WordPress will now recognize the text as an English text. If the user now switches the site language, the equivalent of the text in the new language will then be displayed.

Below is an example of TranslatePress’s multilingual catalog with a list of all the plugin’s gettext localization functions.

how to translate wordpress plugin multilingual catalog

But WordPress doesn’t generate text string translations on its own. You’ll need to create an MO or PO file for this purpose. This type of file contains a comprehensive list of the equivalent gettext strings in multiple target languages. You’ll need to create unique language files for every language you want to translate your plugin into. Fortunately, TranslatePress does this for you automatically.

Prerequisites for Translating a Plugin

Just before going through the guide on how to translate your WordPress plugin, there are certain resources you need to get.

The first 3 requirements are unique file types that are a part of the GNU framework. They include:

  • A Portable Object Template (POT) file: This is the original file that contains all the texts within a plugin’s code that are available for translation. All other translation resources check this file to generate an equivalent translation in a target language. The entire translation process begins with creating a POT file from the plugin’s source code.
  • A Portable Object (PO) file: As a step further, a PO file translates the text saved in the POT file into the target language. This type of file contains both text in the source language and the translation in the target language. A typical PO file is named in this format: ‘plugin name-language code.po’ e.g. ‘translate-press-en_US.po’
  • A Machine Object (MO) file. As a final step, the PO file will then be converted into a machine-readable format—an MO file. This file contains the same content as the PO file but in a computer-friendly format.

Most of these files are automatically created by a powerful WordPress translation plugin like TranslatePress. But you need to first ensure that the plugin is translation-ready. In other words, confirm that the plugin has a POT file in its file directory.

You can find this file by checking wp-content\plugins\plugin-name\languages in the local or web hosting directory.

how to translate wordpress plugin locate pot file

If your plugin file directory doesn’t have a POT file or the ‘languages’ folder, you can easily create one using Eazy Po or Poedit.

Once you have your POT file, your plugin is now ready for translation.

We’ll now show you how to translate your plugin with the best WordPress multilingual pluginTranslatePress.

How to Translate a WordPress Plugin (3 Easy Steps)

TranslatePress is a feature-packed translation plugin that makes it easy to create multilingual WordPress websites with little or no prior WordPress or coding experience. The plugin allows you to translate any part of your WordPress plugin. This includes gettext strings and even user-generated content as well.

It also offers an easy way to translate your entire site on the front end. You get a beginner-friendly interface that supports WYSIWYG translation editing. TranslatePress is compatible with any plugin. You can also use it to translate other parts of your site like the theme and even custom post types.

Ready to translate your WordPress plugin? You can do this by following these steps.

Step 1: Install and Activate TranslatePress

To get started, you can get your free copy of TranslatePress here. You can also find the plugin by going to Plugins → Add New within your WordPress dashboard. Then type ‘translatepress’ in the search bar.

how to translate wordpress plugin with wordpress multilingual plugin translatepress

Once you find the plugin, click Install Now then Activate.

That’s it! The WordPress multilingual plugin is now ready for use.

This free version contains all the features you will need to fully translate your WordPress plugin. But if you want advanced features like DeepL integration, multiple languages support, or a multilingual SEO pack, you’ll need to upgrade to one of the TranslatePress premium plans.

Step 2: Configure Your Default Translation Settings

After adding TranslatePress to your site, it’s time to configure the plugin’s default settings. You can do this by navigating to Settings → TranslatePress. In the General tab of the settings page, you can start by selecting the default language of your site and the additional target languages.

translatepress settings set languages

You get to choose whether you want the translation to be informal or formal. This applies to the automatic translation feature using Google Translate or DeepL integration.

The next step is to set up the language switcher which will appear on the site’s front-end.

To customize it, scroll down to the Language switcher section of the General tab. Here, you can edit its appearance by choosing the location to display it on the screen or whether to add the switcher as a menu item, in a widget, or somewhere else.

translatepress translate wordpress plugin customize language switcher

Finally, you also want to decide how your site should translate the plugin text strings and other site content. To do this, toggle to the Automatic Translation tab.

translatepress wordpress multilingual plugin enable automatic translation

If you enable automatic translation, you’ll be able to choose between the Google Translate API or DeepL API integration. The Google Translate translation engine is available to you for free, while DeepL automatic translation requires a paid TranslatePress package. But regardless of which service you choose, they both need you to retrieve an API key first. So, if you want to go with automatic translation, check these guides on how to generate an API key for:

Manual translation can sometimes be your best bet at getting accurate results that are truly localized and have the desired impact on your target audience. We’ll be using this method in our last step of this guide on how to translate a WordPress plugin.

Step 3: Translate Your Plugin’s Text Strings in the Live Editor

Since we’ve already prepared our plugin for translation, we can now go ahead and start translating in the live editor on the front-end.

Go to any of your site pages where the plugin’s text strings are displayed while logged into your admin account. Then click Translate Page in the top panel of the page.

Access translation interface to turn WooCommerce multilingual for free

On the next page, you can edit any of the text strings visible on your WordPress page.

String List get text strings from woocommerce product

As you can see, gettext strings from active plugins on the page are also available for translation in this list.

Alternatively, you can also simply hover over any text string and click the edit icon to translate the text.

You may find that some of the gettext strings are already translated. That happens when the plugin you’re translating is designed to be translation-ready either by the plugin’s developers or contributors. If that’s the case, you can still alter the provided translation to your liking.

Edit translation from woocommerce plugin using translatepress visual translation editor

With this beginner-friendly interface, you can easily translate every part of your WordPress plugin. This includes both static gettext strings and user-generated content too.

When you’re done entering the translations in the necessary languages, click Save translation. TranslatePress will automatically save your translation in the required PO and MO files in the plugin’s language pack.

If language files were previously available with your plugin, TranslatePress will also pre-load those translations for the text strings. This way, you don’t have to translate everything from scratch.

Translate Your WordPress Plugin Today

WordPress plugins form a critical part of the WordPress development cycle. If you’re going to adapt your website to serve the diverse multilingual WordPress community worldwide, then it makes sense to learn how to translate WordPress plugins too.

This can help you internationalize your product as a plugin developer, contribute to a plugin’s translation project, or simply localize your site content to reach a much wider audience.

Whichever the case, WordPress plugin translation is a rather simple straightforward process. All you need to do is:

  1. Install and activate a powerful WordPress multilingual plugin like TranslatePress;
  2. Configure your site’s default translation settings;
  3. Translate your plugin’s text strings live.

Following this process, you get to fully internationalize your content or product completely at no extra cost to you at all.

TranslatePress Multilingual

TranslatePress is the easiest way to translate your WordPress site. It's fast, won't slow down your website, works with ANY theme or plugin and it's SEO friendly.

Get the plugin

Or download FREE version

We hope this article has helped you learn how to translate a WordPress plugin. Also, kindly let us know if you have any questions in the comments section below.

If you found this post helpful, please check out our YouTube channel, where we constantly upload short & easy-to-follow video tutorials. You can also follow us on Facebook and Twitter to be the first to know each time we post.