The default language for WooCommerce Memberships is English. As of November 2019, we also began shipping a Japanese translation. So what happens when your shop is en français or in italiano or auf Deutsch? Don’t worry: we’ve got a solution for you too. Here’s how to get WooCommerce Memberships to work for you in your language.

Like all SkyVerge plugins, WooCommerce Memberships can be translated. This is done with the use of a textdomain, which is a way for WordPress to know what piece of software you’re targeting for translation. We can target the text used by WooCommerce Memberships by using its textdomain:  woocommerce-memberships.

Getting started

Navigate to the plugin folder on your web server (wp-content/plugins/woocommerce-memberships) and find a folder called i18n. (“i18n” stands for internationalization, because it starts with i, ends with n, and has 18 letters in between.) Clicking on the i18n folder shows another folder called languages. Clicking on that, you’ll see that there’s a file called woocommerce-memberships.pot.

A .pot file is the template on which all translations will be based. The woocommerce-memberships.pot file contains all the text used by the Memberships plugin. We recommend using the free Poedit app to open, edit, and insert your own translations in a .pot file.

Translating the text

Open Poedit and then select Create New Translation.

Create New Translation in Poedit.

Then, open up woocommerce-memberships.pot.

Next, select the language and locale for your translation. Let’s say you’d like to translate WooCommerce Memberships into French (from France, not Canada or any other variation). Select that language in the dropdown list. One selected, click on OK.

Select the language of the translation.

You’ll now see all the text strings from WooCommerce Memberships, then the (empty, for now!) translation section.

The translation strings from WooCommerce Memberships.

You can now start translating these strings. For example, Make a copy in French would be Faire une copie, so I typed that in the Translation box.

Adding a translation.

It’s important to note that Memberships has more than 1,000 strings of text to translate. You may not need to translate all of them. If all the site administrators are fluent (or proficient) in English, you may not want or need to translate strings related to the backend that are only visible to administrators.

Saving the file

Once you’ve finished translating, save the file using the plugin’s textdomain and the country and language code (known as the locale) for your specific version of that language. It’s important to include the textdomain, not just the locale default, so WordPress knows which plugin is affected by the translation.

I don’t want to save it just as this, which is the default in Poedit:

Don't just save a translation like this.

That wouldn’t work because I’m not using the textdomain to tell WordPress which plugin is being affected by this file.

So I need to first type in the textdomain. For WooCommerce Memberships, it’s woocommerce-memberships. You’ll also want to add a “” (hyphen) after the text domain to separate it from the locale. So your filename should look like this:

The proper save name of a translation.

If this translation were for French Canadian users, I’d save the file as woocommerce-memberships-fr_CA. (You can find more about locales here.) Note: It’s important that the locale matches your Site Language in WordPress.

Site languages.

The file you’re saving from Poedit should end in .po, so we should be saving it as woocommerce-memberships-fr_FR.po and it’ll automatically generate a woocommerce-memberships-fr_FR.mo to go along with it. You’ll need both of those files for the translation to be visible on your site. (Here’s a summary of the differences between .pot, .po., and .mo files, if you’re curious.)

Where should the files go?

You can save the files in the same spot you found the .pot file, so for our WooCommerce Memberships example, this would be in:

wp-content/plugins/woocommerce-memberships/i18n/languages/

However, this has the possibility of being replaced when you update your plugin and that file could be overwritten in a future update! As such, you may want to keep all your translations in:

wp-content/languages/plugins/

Because you’re using the plugin’s textdomain and locale, WordPress knows when to use the .po file you created and the .mo file that was generated for it, even if they’re not in the plugin’s folder. (Note: While saving your translation files in the plugins folder will work for all SkyVerge extensions, it may not work for every extension you encounter. Make sure to read up on whether your other extensions require translation files to go in the languages folder.)

All done!

That’s all there is to translating WooCommerce Memberships! Have you created a translation that you’d like to share with us? Contact us today for potential inclusion in a future release.

Published by Julie Martin

Julie Martin is a Customer Support Specialist at SkyVerge. She's based out of Montreal, Québec, Canada and is always happy to help out people in English or en français. In her spare time, she writes creatively and works on her own PHP coding projects, usually while listening to the Barenaked Ladies on full blast.

Leave a Reply

Your email address will not be published. Required fields are marked *