How to localize and translate a WordPress plugin – An in depth guide for plugin developers

How to localize and translate a WordPress plugin – An in depth guide for plugin developers

When developing a plugin, it’s always good idea to make it translation ready as it could additionally reach audiences who do not use English as their first language. If you were wondering how important a translation option is, you can check the repository and see that every single popular plugin is available for language localization. You will find this option is available with UpdraftPlus, MetaSlider, WP-Optimize, Contact Form 7 and WooCommerce, as well as many more. These are some of the most popular plugins available and are coded in a way that allows anyone to translate them easily into their native language.

The purpose of this blog is to demonstrate to our readers how they can code a plugin so that it will be localized and translated into any supported WordPress language. For example, if we wanted to translate a plugin into French, the following steps will allow plugin translation and also make it ready for all supported WordPress languages.

Getting Started

When creating a plugin, we should make sure that we load the plugin text domain. WordPress provides this function:


This code will load the plugin’s translated strings. It may seem a little confusing, but keep reading and we’ll explain how it works shortly.

First, let’s take a look at how to add this function to our plugin code. In your plugin folder, create a directory called ‘languages’. Next, add the below code to your plugin main file.

* Load plugin textdomain.
function plugin_load_textdomain() {
load_plugin_textdomain( ‘udp’, false, basename( dirname( __FILE__ ) ) . ‘/languages/’ );
add_action( ‘init’, ‘plugin_load_textdomain’ );

In the above code, we keep the first parameter (domain) as ‘udp’. We should keep this domain name as per our name of the plugin. The second parameter defaults to false. The third parameter is the path of our ‘languages’ directory. This code keeps our translation files ready on the WordPress initialization.

Use of __() and _e() Methods

As we are aiming to make our plugin available in all languages, we should wrap all our plugin text inside either:

__() or _e() functions.

It is very easy to use these methods. Both methods work exactly the same but there is a rule for using both.

In our plugin code, we normally have two types of text. The first is wrapped in HTML directly and the second is displayed using PHP echo function. Below are examples of both types:

Type 1
[php htmlscript=true]

My Plugin Title


Type 2


The general rule is that if you are printing text using PHP echo then you should wrap text in the following code:


If it is in HTML then use the code:


The above code should be written in the following way:




Type 2
[php htmlscript=true]


As can be seen in the above examples, the second parameter was written as ‘udp’, which is our plugin text domain. By using this domain, it will allow us to later translate our text into any language. This is how other plugins make their plugins translation ready.

If you wish, you can check our plugin:


If you search for the text domain ‘updraftplus’, you will see how our plugin’s text is wrapped inside __() and _e() functions.

Create a Sample Plugin

The next stage is to create a sample plugin with the some text so we can test our translations. First, create an ‘udp’ folder in your plugin directory. Inside this folder create the file: udp.php and the folder languages. Next, add the below code to the plugin file.




Create the Translation Files

To generate our translation files, we will use the following translation editor software:


Translation files (.po and .mo) contain the string to translate and the translated string. While creating the .po file we need to save it in ‘{domain}-language code’ format. In this example, the file will be udp-fr_FR.po.

Next, install the POEDIT software on your system. This software is available for all platforms and can be installed on Windows, Linux or Mac.

Once installed, open POEDIT and go to File->New, where we will enter our language code in the window prompt.

Click on the ‘Save’ icon, after which, the file explorer will open. Head over to the plugins languages directory and save it as the following: udp-fr_FR.po.

Now we are able to add the French translation for our plugin text. To do so, click on the ‘Extract from sources’ section.

This will open a catalog properties popup. We now need to configure the three following tabs: Translation Properties, Source Paths and Source Keywords. In the Translation Properties tab, add our domain ‘udp’ as the project name. Source Paths will be our plugin folder and we will add ‘__ and _e’ inside Source Keywords.

If you have multiple folders inside the plugin, then we will need to choose each directory individually.

After selecting the plugin folder you should see ‘.’ in the Paths section. Repeat the same process for other folders inside your plugin directory if necessary.

Under the Source Keywords, click on the + icon and add ‘__’ and ‘_e’ as a keyword and click the OK button.

In the next window, under Source text, you will have all strings available to translate from your plugin. Choose the string one by one and add your French translation to the string.

Once you add all translations, click on the Save icon. This will automatically save all your string translation in your udp-ft_FR.po file. Your .po file will now contain the following code:

#: udp.php:24 udp.php:25
msgid “UDP Setting Page”
msgstr “Page de configuration UDP”

#: udp.php:37
msgid “My Plugin Title”
msgstr “Titre de mon plugin”

Test Our Plugin Translation

We have now completed the task of creating .po and .mo files for our plugin. Now it’s time to test our plugin and check the French language translation.

First, download our language file from the following address:

WordPress Language repository.

For the French language, the path is as follows: and fr_FR.po

Download files from this link and store it in the wp-content/languages directory. Create the ‘languages’ folder, if it does not already exist.

Next, we need to change the default language of our WordPress installation. Open the wp-config.php file and add the language as follows:

define(‘WPLANG’, ‘fr_FR’);

Now if you go to the dashboard, your plugin should be displaying in the French language.

In conclusion

Creating a localized translation for your WordPress plugin can seem a little daunting and complicated at first. However the potential benefits of offering large non English speaking countries like Brazil, France and Germany your plugin in their native language can help open your plugin up to a whole new, appreciate audience. While it may seem like a lot of work, the rewards could be considerable.

The post How to localize and translate a WordPress plugin – An in depth guide for plugin developers appeared first on UpdraftPlus. UpdraftPlus – Backup, restore and migration plugin for WordPress.

WordFence reporting false positives when virus-scanning

If you are using Wordfence’s security scanner, and having it tell you that you have a virus “Backdoor:PHP/SEemf0Ji” in the file phpseclib/tests/Unit/Crypt/RSA/LoadKeyTest.php inside UpdraftPlus, then this is a false positive (*). You can compare your file with the original file from the phpseclib project here – – containing the same string which Wordfence wrongly identifies as a virus as a test RSA key in a harmless context.

If you get this report, then please do report this to Wordfence if you can. The number of times their plugin continues to flag false positives in different places is a non-trivial support burden and we wish they would implement some technology to remove the easy-to-discover false positives like this one, especially in a top-20-most-installed plugin like UpdraftPlus. It is a burden upon their users too; we presume you prefer to do real work than read and investigate incorrect reports!

(*) Of course, at this point, now that this is known to be a widespread false positive, injecting that virus in that file would be a smart move for any hackers. This is another reason why false positives. So, to be entirely sure you’re safe and err on the side of being over-cautious rather than otherwise, you will want to test that the file is identical to the pristine version linked above.

David Anderson (lead developer)

The post WordFence reporting false positives when virus-scanning appeared first on UpdraftPlus. UpdraftPlus – Backup, restore and migration plugin for WordPress.

Colour blindness, WordPress and how to make WordPress sites accessible to those who can’t see colour

Colour blindness, WordPress and how to make WordPress sites accessible to those who can’t see colour

As part of Colour Blind Awareness Day 2018 I thought I would share my experiences.  I first discovered I was colour blind at the age of 7 while in class at primary school, looking at a chalkboard and struggling to read the yellow writing. After this incident I went to have my eyes checked and sure enough, I was diagnosed as colour blind.

So what is colour blindness? Colour blindness affects 1 in 12 males and 1 in 200 women. Until recently, I had believed that colour blindness only affected men as this was the common belief when I was growing up. But we now know that even though it is a lot less common for women, they can also suffer from this type of visual impairment.

colour blindThe classic colour blindness test can be carried out using Ishihara plates. If you can’t see the number 3, then you’re probably colour blind.

Attitudes, awareness and the development of colour blindness friendly software has changed a lot since I was first diagnosed. But is it enough?

When you are building a website or designing a plugin, there are 3 types of colour blindness that will need to be taken into consideration:

Red-Green Colour Blindness

This is the most common form of colour blindness which is split into 4 types:

Protanomaly: Red, orange, and yellow appear greener and colours are not as bright.
Protanopia: Red appears as black. Certain shades of orange, yellow, and green all appear as yellow.
Deuteranomaly: Yellow and green appear redder and it is difficult to tell violet from blue.
Deuteranopia: Sees reds as brownish-yellow and greens as beige.

Blue-Yellow Colour Blindness

Blue-yellow colour blindness is rarer than red-green colour blindness. This is split into 2 types:

Tritanomaly: Blue appears greener and it can be difficult to tell yellow and red from pink.
Tritanopia: Blue appears green and yellow appears violet or light grey.

Complete Colour Blindness

People with complete colour blindness (monochromacy) don’t experience colour at all and the clearness of their vision (visual acuity) may also be affected. These are split into 2 types:
Cone monochromacy: Have trouble distinguishing colours as the brain needs to compare the signals from different types of cones in order to see colour.
Rod monochromacy or achromatopsia: Rare and the most severe form of colour blindness. People with rod monochromacy see the world in black, white, and gray.

(Information from National Eye Institute (NEI)

Personally, I have Deuteranopia. But colour blindness varies from person to person and can be present in different levels and have varying effects.

Over recent years WordPress have really upped their game concerning colour blindness accessibility with the Make WordPress Accessible project and the inclusion of the A11Y Project.

The A11Y Project is a must for any web developer as it doesn’t just cover WordPress, but can also be used to improve accessibility for all websites. The project has an abundance of resources, material and help to assist in making the internet accessible to all.

Here at UpdraftPlus we use these tools so our plugins are accessible to everyone. One great tool that we have used for colour clarity is the tanaguru contrast finder. By inserting the HEX of a colour we want to use, it allows us to determine if the selected colour is compatible and recommend alternatives if not.

Despite working for UpdraftPlus for several years, it was only around a year ago that I discovered that our brand colour was orange as due to my colour blindness I had always thought it had been red! Luckily it doesn’t hinder my ability to see other text and images that are used within the colour scheme and hasn’t hindered my use of the products.

This does however show the importance of why developers and designers must all take the time to use features like A11Y and other accessibility tools, so that all plugins, websites and apps are accessible for everyone.

The post Colour blindness, WordPress and how to make WordPress sites accessible to those who can’t see colour appeared first on UpdraftPlus. UpdraftPlus – Backup, restore and migration plugin for WordPress.

Important – new privacy centre & how do YOU hold user data on your WordPress site?

Do your WordPress sites contain EU user or customer data?  If so, today is GDPR day which means you now legally need to consider the privacy and security of their data whether or not you’re in the EU.

If you backup your WordPress site with EU user data, then you need to consider the security of those backups. UpdraftPlus Premium can protect the customer data in your backups by encryption and lock settings access. It can also delete old backups, which is another important consideration as you mustn’t keep unused EU user data under GDPR.

If you’d like to see our own privacy policies on how we protect your data (or unsubscribe from this newsletter), then we’ve built a helpful privacy centre here.

The post Important – new privacy centre & how do YOU hold user data on your WordPress site? appeared first on UpdraftPlus. UpdraftPlus – Backup, restore and migration plugin for WordPress.

GDPR compliance with UpdraftPlus: encrypting the databases in your WordPress backups if they contain user data

GDPR is an important new data regulation coming into force soon across the whole of the EU. We’re working on fully complying ourselves with our own customer data, and have launched a Data and Privacy Centre here:  This should be fully complete within the next few days.
As part of the law, many customers are asking if our software helps them be compliant.  We’ve put out details on what information we collect here.

One thing you need to ensure is that your backups of your customer’s private data are protected. To help with this, UpdraftPlus Premium can encrypt the data in your backups. It has an industry-standard AES encryptor keeps all of the sensitive WordPress installation data (e.g. passwords, lists of users, secret keys, etc.) stored in your database completely secure. Find out more here:

The post GDPR compliance with UpdraftPlus: encrypting the databases in your WordPress backups if they contain user data appeared first on UpdraftPlus. UpdraftPlus – Backup, restore and migration plugin for WordPress.