Poedit pro (formerly known as poedit) is a free (professional version charge), open source and cross platform gettext class (. Po format, gettext is used in the application program for program internationalization) International Translation editor. It is also one of the most widely used software of the same type. At present, it is available in UNIX + GTK or windows platform with wxWidgets, and released with MIT license.
It is built into wxWidgets tool and can run on all platforms it supports, such as GTK + under UNIX and windows. Poedit provides a more convenient way to edit the directory, instead of manually editing by starting the VI text editor.
Update Po file from pot
If after you have translated a PO file, the program that uses the Po file is upgraded. At this time, the new program may contain vocabulary items that are not in the original Po file, or the previous vocabulary items may no longer be used in the new program. How to update?
One method is to extract the Po file from the new program, the other is to use the pot file to update automatically.
Generally, the author of the program provides a pot file (some Po is a suffix, which needs to be manually modified to a pot suffix), which contains the latest vocabulary items for you to update. The suffix of Microsoft Office PowerPoint template file is also pot, please don’t make a mistake.
In the poedit menu bar, select “item” update from pot file… ” , select the latest pot file to update.
Using TM (translation lexicon)
For example, the Po file of a plug-in of WordPress is translated. Because the professional terms are generally related or the same, many words in the Po file may have been translated, such as in the ZH of WordPress itself or other plug-ins or themes_ CN.po File. With the TM (translation memory) function of poedit, we can make use of the translation achievements of our predecessors instead of starting from scratch.
First collect some translated Mo files related to the program you want to translate. TM uses Mo instead of Po.
First, create a translation thesaurus in poedit.
1. In the menu bar of poedit, select File preferences, open the preferences dialog box, and select the translation thesaurus panel, as shown in the figure below.
2. Click the “add” button to add the language “zh (Chinese)”, as shown in the figure above, “zh” appears in “my language”.
3. The “path to DB” can remain the default. This is the storage location of the translation thesaurus created by poedit. If necessary, it can be backed up.
4. Click the “generate database” button to open the “update translation Thesaurus” dialog box, as shown in the figure below.
5. In this dialog box, click the “add file” button and select the location where you collect Mo files. Poedit will automatically search Mo files and list them. Click the “next” button to generate a translation thesaurus. At this point, the translation thesaurus is created, and you can update the supplementary translation thesaurus in this way in the future.
How to use translation thesaurus is very simple.
Open a PO file that needs to be translated, and then select “category” in the poedit menu bar to use TM automatic translation. Poedit will automatically extract exact or fuzzy matching translations from the translation thesaurus. The translation of fuzzy matching is generally shown in bold, which can be determined by “Ctrl + U”, or the right mouse button can be used to select the appropriate translation.
The singular and the plural
Integer denotes the number of singular and complex forms of variation, and its value is a positive integer. There is no distinction between the singular and the plural in Chinese, Japanese and Korean, that is to say, there is only one form of variation of the singular and the plural, so there are two forms of expression of the English singular and the plural, so there are two forms of expression of the English singular and the plural, so there is no distinction between the singular and the plural. If there are four kinds of singular and plural changes, the value of this expression will include 0, 1, 2 and 3, corresponding to the translated version msgstr , msgstr , msgstr  and msgstr . So, sometimes this expression is quite complicated. In Chinese, just plural = 0 and msgstr  should be kept in the translation.
Using shortcut keys
Translation is a physical work, the use of shortcut keys can definitely improve efficiency.
(1) using “Alt + U” can confirm fuzzy translation.
(2) using “Alt + C”, you can copy the items to be translated into the translation column.
(3) use “Ctrl + F” to find the matching text.
Using the find function
To be good at using the search function can also improve efficiency. You can directly copy the text to be translated in the program interface, and then find the relevant text in poedit. The vocabulary entries in the Po file are sorted according to the program source file first, followed by the location in the source file. If a word does not know where it is, it is usually in the same file as the words before and after it, which may be in the same interface.
In general, choose “search in the original” and “search in the translation”.
View program files
When translating some words, they may not know how to translate because they are separated from the semantic environment. In addition to viewing the relevant vocabulary directly in the interface, you can also view the source program file where the vocabulary is located.
Chinese WordPress Theme and plug-in with poedit
As we all know, WordPress is a very popular open source blog / CMS program on the Internet. Many webmasters from different countries are using WordPress, so WordPress also provides powerful internationalization function to support different languages and texts. However, many times, the official localization translation of WordPress is not satisfactory, and the themes and plug-ins developed by some developers for WordPress are not perfect in terms of internationalization. In China, many WordPress Themes and plug-ins we use are developed by foreign developers. Most of these themes and plug-ins have not been sinicized or are not perfect. At this time, we need to complete the final Sinicization work ourselves.
WordPress usesGNU gettextTo achieve internationalization. As users, we don’t have to go deep into the underlying implementation, we just need to know how to realize internationalization in WordPress.
In WordPress, functions are generally used__ () and_ E () to identify the place to be translated. For example, if we want to translate the English “hello” into Chinese “hello”, we just need to write the following code in the corresponding display place:
<?php echo __('hello', 'Codex'); //Codex is the name of the corresponding theme or plug-in. If it is an internal module of WordPress, the second parameter can be omitted. ?>
_e($text, $domain)All are international translation functions of WordPress, but the former__ () returns the translated string, which_ E () is the direct output (echo) of the translated content. In general, the name of the topic will be indicated in the introduction of the topic, and the folder name of the topic is the name of the topic. In addition, you can view the functions.php File, most of which contain the following statements:
load_theme_textdomain( ‘Codex’, get_template_directory() . ‘/languages’ );
Where, Codex is the name of the current topic, followed by
get_template_directory().'/languages'The directory where the translation dictionary file of the specified subject is stored. get_ template_ Directory () means to get the root directory of the current theme or plug-in, so the code above refers to the languages folder under the theme or plug-in directory.
In addition, we need to write the corresponding translation dictionary file. Otherwise, how can WordPress know what kind of Chinese to translate “hello”. The translation dictionary file records a pair of pre translation and post translation text mappings. The suffix of the translation dictionary file in WordPress is. Po. The. Po file is the source file of the translation dictionary, and we need to use tools to compile it into a. Mo file for official operation. The file names of translation dictionaries are usually named (or suffixed) according to the localized language. For example, the simplified Chinese translation dictionary file is zh_ CN.po 、zh_ CN.mo The translation dictionary of traditional Chinese (Taiwan) is zh_ TW.po 、zh_ TW.mo The translation dictionary of English (USA) is en_ US.po 、en_ US.mo …… In this way, WordPress can display the content of the website in simplified Chinese, traditional Chinese or other languages according to the current user’s national language.
In order to make translation dictionary files conveniently and quickly, we need to use poedit. Poedit is an open source, free, cross platform gettext class (. Po file) International Translation editor. It is also one of the most widely used software of the same type.
First of all, we need to download and install poedit. The download address of poedit’s official website ishttp://www.poedit.net/download.php. The installation of poedit is very simple, and there is nothing to pay special attention to. I will not repeat it here.
Next, we open the installed poedit and click the menu file new catalog.
In this case, the following cataloging attribute window will pop up to fill in the corresponding form content according to the actual situation (most of the content can be left blank)
It is worth noting that the form “plural form” can not be filled in by default, but if there is plural form in the text to be translated, it may cause errors in the program. Therefore, it is suggested to fill in the plural as follows:
nplurals=2; plural=(n != 1);
Next, switch to the source path tab of cataloging attributes, as shown in the following figure:
In the basic path text box, generally fill in “.” to indicate the current directory and its subdirectories. However, sometimes, due to the path problem, poedit may not be able to find the specified directory correctly. At this time, you need to manually specify the directory to extract the translation content for poedit. For example, if I want to translate the theme epublishing into Chinese, I will manually enter the local path of the epublishing theme D::? PHP? Codeplayer? WP content? Themes? Epublishing. )
Finally, switch to the source keywords tab of cataloging attributes, as shown in the following figure:
The keywords here fill in the functions we use in WordPress for international translation
_e. In this way, poedit will automatically look up functions in all files in the path we specified (for example, epublishing above)
_eContains the text of the and is listed on the left.
At this time, what we need to do is input the translated result line by line according to the source text content listed on the left. After the translation, click the [save] button in the menu bar, and we have successfully produced a zh that can translate WordPress specified theme or plug-in into Chinese_ CN.po And zh_ CN.mo Documents. Put these two files into the language directory of the corresponding theme or plug-in, and our work of Sinicizing the theme or plug-in is completed.
In front of
__('hello', 'Codex')For example, if WordPress cannot find any corresponding translation, WordPress will directly output the content to be translated (that is, “hello”).