Let WordPress support multi-country language pack

Source: Internet
Author: User
Tags pack
let WordPress support multi-country language pack

WordPress Default theme will have a languages folder, you must know, this is used to put language packs, in which there must be a pair of mo/po files. If you have some foreign WordPress theme or plug-ins have Chinese experience, then you must know that we can use poedit this small software to modify the Po file, so that the theme of the Chinese. To submit to WordPress official Theme Station friends, I think that the theme to support a multinational language is very useful, after all, to let my theme and international standards, and then separate the language from the code to facilitate the two times when the development of unified management. So how do we make WordPress support Multi-Language when we do the theme? Here, I would like to speak briefly on the theme of English Chinese-language packaging process.

The first step is to define a directory of language packs for the WordPress theme, adding the following code to the functions.php: Load_theme_textdomain (' Wange ', TemplatePath. '/languages ');

The second step is to use a function in the topic to output the original English text, for example: <?php _e (' Welcome to Life Studio ', ' wange ');?>

Here needs to explain,WordPress 's translation function has two, one is written above _e (), and one is __ (), the difference is similar to the PHP in the Echo and Return,_e () is the direct output, and __ () just return the value, specific can Look at the official document introduction. Also note that the first parameter in _e () is the part that needs to be translated, and another parameter needs to be the first parameter of the Load_theme_textdomain () functions.php added in the first step, as in the example given the two locations must be wange.

The third step, configure the Poedit software, I use the Chinese version of the Chinese version of the software, so embarrassing.

1, file-New Message Directory Document-engineering information. Fill in what can be filled in, do not know if there are any required, this I have not tried, anyway, it is always true to fill. As shown in figure:

2, then the "path" setting, the basic path is two points, the following path to create a new point, as shown in figure:

3, then Next is the "keyword" setting, the keyword here is the second step mentioned in the two WordPress translation functions, as long as the filling and _e can be, as shown:

The fourth step, with Poedit to configure the translation file, click on the interface of the third position of the small blue ball can automatically get the path of the translation function, and then listed, the need to translate the text input in the bottom can be, and then click Save. Poedit automatically generates PO and Mo files in the specified directory.

This is OK, this is my time to do the theme of some of the experience of retelling, there may be missing places, but also please point out Kazakhstan.

In addition, in the process of production I found a problem, that is, if the theme has a background control Panel, the translation of the document how to deal with it. The theme of the backstage is with hooks, so according to my understanding, translation files should be used is also the default WordPress language Pack, so that one can not freely to the background of the translation, what way to the language pack and path with hooks hook together. Or there are other ways. Also ask the Master to guide the ~ category: 17~wordpress
Sautéed peanuts
Attention-0
Fans-390 + attention
«Previous: Extract the multilingual system in WordPress
» Next: Php GetText Way to implement UTF-8 international multi-language (i18n)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.