![]() WordPress uses gettext as its translation system. What are those files? Basically, the translated strings are all contained in a. mo files, contained in the files of your WordPress site, and which contain the. There is a free version and a premium version, starting at 29.99 (i.e 34) for one year of use. It is not a plugin, but a tool external to WordPress. mo file which is a machine (binary) optimized version of the corresponding. Poedit is a software to translate your WordPress themes and plugins. This file is a text file containing pairs of string IDs and strings to be translated. This guide is composed of three chapters: We will explain how to produce those files. Ready ? Translate an existing plugin 1 – Grabbing the sourcesįirst you will have to grab the latest plugin sources, usually at the WordPress plugin homepage. We will often take the example of our plugin Counterize. Go to and click on the orange “Download” button to get it. Once you downloaded the file, just extract it in any directory. ![]() Let’s say you extracted it in “ /home/yourname/web/counterize/“: this directory should now contain all the plugin source files. ![]() You can see that there are already some translations contributed by other people. A Theme’s default translation template is located in THEMEXXX/lang/YYY.po, where THEMEXXX is the name of your theme and YYY default language of the theme. Open Poedit and select Create new translation: A new window will pop up, select the WordPress theme you want to translate. If your locale is not included, then this is your chance to be part of the contributor list! 2 – Determining the “text domain” of the pluginĮach plugin to be translated must use a unique text domain. Step 1 Opening Your Theme’s Default Language Template. It should not be too generic to avoid conflicts. There are good chances that the plugin author already defined a text domain for his plugin. String like these help you to find the text-domain _e ( 'Referers', 'counterize' ) //String like these help you to find the text-domainįor example you will find the following string in the Counterize plugin: Just look at the sources and search for the strings “ _(” or “ _e(“. This shows that the text domain is “counterize”. Of course it will be different for each plugin. pot file is a model that will be used later to create your own translation. pot file in its source, then you can use it and go directly to the next part of this chapter. Otherwise, we explain how to get such a file below. pot file: A – Using the xgettext command-line tool Poedit wordpress tutorial how to# Most Linux distributions come with gettext installed. Among the files installed by the gettext package, you will find a command-line tool named “xgettext”. Xgettext -default-domain=counterize -language=PHP -keyword=_ -keyword=_e -sort-by-file -copyright-holder="Hautclocq Gabriel" -package-name=counterize -package-version=3.0.18 -msgid-bugs-address="" *.php Consider the following command line I used for Counterize: So open a terminal and cd to the directory where you extracted the sources (such as /home/yourname/web/counterize/). I will now explain a little what each part of the command line is: This command grabs all the strings to be translated and save them in a file named “counterize.pot”.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |