Translate themes and plugins from WordPress • WordPress Help

If you've ever thought of translating a topic or plugin you might have backed off because of the hassle of having to learn to use a new tool and have to upload files by FTP, but that are things of the past.

Currently it is no longer necessary at all or use the known PoEdit or similar, much less upload files by FTP to WordPress once edited, now you can do it all from the desktop of WordPress and in such a simple way that seems to be a lie that has not always existed.

I mean a jewel plugin call Loco traducir that, once installed, allows to modify the existing translations of your themes and plugins and even create new ones all in a very simple way and without having to learn practically nothing new. [19659003] Nothing else installed arlo a new menu item appears in the sidebar of the desktop where you have everything you need and more.

The first step is to go through the plugin settings, where you basically choose if you want to use the editor PO integrated or an external one

 settings loco translate wordpress

You can also configure backup copies of the translation files (PO) or even if you want to activate the translations of the same WordPress . If you activate it in " Enable WordPress core translations " in the list of packages you will also see the same WordPress at the end to put them to your liking.

 translations wordpress core loco translate

The following is to go through the existing packages, a simple but intuitive screen where the installed themes and plugins are displayed and the list of available translations .

 packages available loco translate wordpress

Editing an existing translation is as simple as clicking on it, which opens the editor and you can start modifying it to your taste. When you finish you click on " Save " and you already have it.

 existing po editor integrated loco translate wordpress

In case you do not There is translation available in your language you simply click on the link " New Language ", which takes you to a screen where choose the language you want to create .

 editor po new integrated loco translate wordpress

Save the changes and open the PO editor directly to start include your translation strings of the original texts . Again, you save the changes and the theme or plugin is already in your language.

 editor po translating new crazy translate wordpress

Another virtue of the editor is that you can share your translations simply using the buttons for download the PO and the MO, and let others enjoy your translations . And, in addition, you do not need to always have the plugin active, it's useful: you activate it, use it and turn it off if you want; you will not lose anything of the done, the translations are created and will continue there.

There are other plugins that offer this type of functionality, like Codestyling localization but, honestly, there is no color, Loco translate it is much simpler and intuitive to use, with practically no learning curve, which will contribute to the main current goal of the WordPress community: internationalization .

What are you waiting to start and share your translations?

NOTICE : this publication is from two years ago or more. If it's a code or a plugin it might not work in the latest versions of WordPress, and if it's a news story it might be obsolete. Then do not say we have not warned you.

Loading …

That may also help you:

Prepare WordPress plugins for translation • WordPress Help

Some time ago we saw how prepare WordPress themes for translation but also plugins gain more popularity, and ultimately They are more useful for all types of users if they are prepared for translation. In such a globalized world, it does not make sense to restrict the popularity of a plugin to only the language of a few, no matter how many? .

The process, similar in some aspects, to that of the topics, passes through a good series of steps that add task to the definitive publication of the plugin but that, without a doubt, will make your plugin add many points in favor of the WordPress user community .

Internationalization vs. localization

Before you can internationalize your plugin you should know what this means. Also known as i18n it means modifying the plugin so people from other languages ​​can easily use your plugin.

Localization is the pure and hard process of modifying the plugin to another language. However, internationalizing entails much more than simply translating the plugin's interface. For example, use of metric system or Anglo-Saxon units, punctuation marks to separate thousands, and all those particularities.

Although the following guide is location-oriented do not forget those additional factors, to take them into account.

Domains and initialization

Locating your plugin means that you have to have a text domain, keeping each separate from the rest that WordPress or other plugins use. It does not matter what you want to use as a text domain but choose something unique, if possible that is related to your plugin.

Before locating your plugin completely you will have to tell WordPress how you can find your text strings. If the code does not exist you will have to insert something like this:

This code communicates with WordPress and tells it to use the function called myFunction when it loads. Then, this function will give WordPress the name of your text domain and will teach you how to load the localized text strings, something like this:

The WordPress function load_plugin_textdomain informs WordPress that there is a text domain called mydomaintext and that the files that have the localized strings are in the server folder wp-content / plugins / miplugin . Of course, the conventions used in this article should be changed by your folder path, text domain name, function name, etc, I think you already imagined it but it never hurts to remember it.

Preparing the chains

After initialization you will have to change the static strings for a function that allows WordPress to use the appropriate localized version of that string. More than anything for WordPress not to use the wrong language.

This function offers a short name that facilitates internationalization: the function with double low bar __ (string, domain) . The function has two parameters, the first is the string that the plugin uses by default if there is no localized version available, and the second parameter is the same text domain that you chose in the previous code.

Before we get this step our code would be like this:

And then it would be in this way:

Location

Once all the previous preparations have been made, you will be ready for the actual process of making your WordPress plugin available in several languages.

Creating a location for your plugin requires making a file ] .po with name similar to the file of your plugin, and with the ISO 639 codes of two letters for each country and language. For example, if your plugin is called "miplugin" and you want to locate it in Spanish of Spain it would have to be called the file: "miplugin-es_ES.po"

Although the WordPress codex offers tools that can help localization often it is better to simply pull the file .po from another plugin as a base. The files .po are made with a simple header and then the translation pairs:

The msgid is the standard string that appears in the function double low bar that you defined. Once created the file .po you can use any tool to create the files .mo which is the other file that WordPress requires for the translation, and actually the only one that will read for do it Personally, I recommend you use PoEdit which is also cross-platform.

Let other translators help

Nobody knows all the languages, at least nobody I know, so if you want to expand the popularity of your plugin the best thing is to increase your resources and allow others to translate your plugin.

Now, this requires a special procedure to generate the necessary files to offer the translators, since you will not pass them the source code so that, by mistake, break something they should not, right? That being a translator does not mean that they are also programmers.

The files that you will have to give to the translators is a file POT which is more or less like this:

There are two ways to create this file. If you have already uploaded your plugin to the repository, go to the administration page and choose "Generate POT file". This file is the one that you will send to the translators to translate the plugin. If you want, sometimes it's a good idea to also send them the full plugin in case they have doubts about where everything is going, so they can install it and see the changes after the translation.

If you do not have the plugin in the repository yet you can go to the WordPress i18n tools directory and use the makepot.php script like this: