How to translate plugin using WPML

WPML simplifies the building of multilingual sites and their functioning. It's powerful enough for corporate sites, yet simple for blogs. With WPML, you can translate pages, posts, custom types, taxonomy, menus and even the theme's texts.

This plugin works with the WPML plugin.

Getting started

First of all, you need to purchase the most recent version of the WPML plugin and include the String Translation and Translation Management modules that you can find inside the package you get after the purchase. These two elements are essential for the correct use of the plugin.

WPML is composed of different modules, depending on the purchased version, and every one offers various options about the translation of your site. Once activated, a tab will appear on the dashboard of your installation and from there you will be able to change all the settings you want.

WPML Language Configuration

Choose the languages you want to set for your site and set the content management in the different languages.

If this is the first time that you configure WPML, select the language of the current content. Later, you can add a language selector in your theme to allow users to change it: you can customize its style and the number of languages to show, as you can see.

Theme and plugin localization

WPML lets you localize plugin with the classic .mo file, or translating the text directly from WPML.

In the first case, it will suggest the translation of many strings, so you will just have to choose the second option from the localization menu and set the domain of the text of the plugin. On the contrary, if you choose the first option as in the image above, you will start the WPML localization plugin scanning all strings, and getting the texts that can be translated. You can add the translation of the relative text from WordPress itself: for further information go to this page.

String translation

With WPML you can translate the YITH Payment Method Restrictions for WooCommerce strings in the desired language.
When we talk about strings, we are referring to all those labels and related contents, from option and widget names to all the texts showed to users with the plugin features.

As a first step go to WPML -> Theme and plugins localization, select the plugin and click on "Scan the selected plugins for strings" (we used YITH Plugin as an example)

Click on String Translation, the entry you can find in the WPML sub-menu.

In the top part of the page, WPML lets you select the "context" in which search for the strings, and to specify the string you want to translate.

To translate the string that you search, select the plugin YITH Payment Method Restrictions for WooCommerce domain. Our sample plugin text-domain is "yith-sample-plugin".

Add the string in the related search field.

Select the entry you want to translate, add the translated string, tick the Translation is complete option and click the Save button.

Now the status will be Translation Complete and the string will be correctly displayed in the selected language.

CONCLUSIONS

WPML offers to users its language selector as a drop-down list of languages: if you are searching for something different, you can always go to this page. for further information.
For more information about the WMPL configuration, please read the official documentation.

Translate manually the plugin

Here you can learn how to translate your product language files manually.
This process requires you to translate the .pot file included in theĀ "languages"folder of the plugin and to set your WordPress site with the matching language.
Let's see how to proceed step by step.

Change the website language

First of all, you have to change the language of your WordPress platform so you can display the translated plugin.

Go to your WordPress Dashboard > Settings > General > Site Language and select your language and then Save.
Your site language will be updated.

Now all WordPress options will be showed in the selected language.

Language file of the plugin

The original language file of the plugin is yith-payment-method-restrictions-for-woocommerce.pot and it is included in the "languages" folder of the plugin. If it does not include your own language you have to translate following these steps.

Download Poedit, the software through which you can translate the plugin text strings. Now open the file yith-payment-method-restrictions-for-woocommerce.pot and click on the "Create new translation" button.

Select the language in which you want to translate the plugin.

Now translate the strings one by one. Once finished, click on the "Save" button and rename the file adding the slug of the plugin to the suggested file name (e.g., yith-payment-method-restrictions-for-woocommerce-it_IT).

If everything worked fine, the .po and .mo files will be created automatically in the "languages" folder of the plugin.