How to customize wordpress theme wordpress plug-ins

Source: Internet
Author: User
Tags install wordpress

There are various versions of wordpress localization tutorials on the Internet. New users often do not know how to develop wordpress. Although veterans know it, they are too lazy to write and share their experiences, here, I wrote a Chinese tutorial for cainiao friends, hoping to help cainiao friends.

Regardless of how wordpress is customized, it is always different. Next we will discuss the localization of wordpress in two ways.

Before we develop a custom wordpress theme or wordpress plugin, we must prepare some useful tools so that we can well develop a custom wordpress theme or wordpress plugin. The tools we want to prepare include: Wamp, Dreamweaver, Poedit, and theme or plug-in that requires localization. Here is a brief introduction to the software:

Wamp: PHP environment package running locally. We use this package to build a PHP environment locally and install wordpress. The same software includes XAMPP and AppServ;

Dreamweaver: simple software developed by PHP. Similar software includes zend studio or EclipsePHP. We only use a small part of its simple functions;

Poedit: The localization plug-in for wordpress Themes;

Styleshop: an e-commerce topic for wordpress. Next we will take this topic as an example to describe how to define the wordpress theme; occasionally provided in the network (http://www.olpie.com/wordpress-themes/wordpress-styleshop );

The above software is just a brief introduction here. If you want to learn more, you can search Baidu or Google.

Even the webmaster olpie has installed wamp, dreamweaver, wordpress, and wordpress theme Styleshop on the computer. I will not describe how to install and use it here. (For more information about how to install WAMP and wordpress, visit this tutorial)

Method 1: directly modify it in the source code;

Wordpress built-in language functions __(), _ e (), _ x (). Here we can directly modify the English part of the language function and translate it into Chinese, then the localization work is completed.

Example: _ ('newer Comments → ', 'styleshop ');

Here, while directly replacing the English part, we should also take into account the HTML tag, and cannot modify the HTML Tag. Otherwise, the integrity of the template will be damaged.

Here we can use Dreamweaver to help us quickly locate the part that requires localization. First, you need to create a site. The site root directory must point to the path of the wordpress template in Chinese. Use the shortcut key "CTRL + F" and select the search range as "entire local site ", enter the content you want to search for and click "search all" to quickly locate the content you want to search for. Then, you can perform Localization on the content. Save the content after localization.

I do not recommend this method here, because for new users, if you do not know which parts need to be written in Chinese, it is easy to cause errors and damage the integrity of the template source code.

Method 2: Use the Poedit software for localization;

1. The template contains a language file.

Generally, wordpress templates outside China contain language Pack files. You can find the corresponding files in the lang or language folder. po ,. pot file. If the template contains. po ,. you can use the Poedit software to directly open the pot file and translate it. Copy the en_US.po file, paste it to the same folder, name it zh_CN.po, and then use the Poedit software to directly open and translate it.

  

 

After the translation is complete, click CTRL + S to save it. A file named zh_CN.mo is generated in this folder, which is a Language Pack recognized by wordpress. If the wordpress system is installed with a Chinese Language Pack, wordpress will call the zh_CN.mo file in this folder. This completes the localization of wordpress.

2. The template does not contain a language file.

If no language file exists in the template, we need to use the Poedit software to automatically generate the po file. The procedure is as follows:

Step 1: Open the Poedit file and click "file"> "create message directory document". A dialog box is displayed.

  

 

Step 2: Enter the text in the pop-up dialog box:

  

 

Some tutorials have pointed out that some parts do not need to be written, but we suggest you write them all to make them perfect, the "Source code Character Set" and "Character Set" are related to the wordpress encoding method you are using, and are generally UTF-8.

Next, find the storage path of the theme you want to localize on the disk, and press Ctrl + F4 to select all the paths and copy them.

  

 

Paste the copied template path to the basic path, click the button in the red box "1" under it, and paste the copied link in the lower box;

  

 

Then, enter "_" and "_ e" at the following position according to the above method ".

  

 

Click "OK". In the displayed dialog box, find the path and file name of the disk, and click "save.

  

 

If such a dialog box appears after saving, it indicates that the Language Pack of the wordpress topic you want to convert to Chinese will be generated.

  

 

Click "OK". The graphic interface shown in method 1 is displayed. Then, you can perform step-by-step translation and save based on the method to complete the localization of wordpress.

At this point, the wordpress Language Pack has been translated. Do not panic if you still find that the pack is still in English when you log on to the background or view it on the foreground. This requires you to use Dreamweaver to open the functions. php file in the template, at the end of the file "?>" Add the following code before:

Function theme_init (){

Load_theme_textdomain ($ domain, $ path );

}

Add_action ('init ', 'Theme _ init ');

$ Domain: identifies a translation as a unique identifier, for example, "StyleShop" in this example ". _ ('Newer Comments → ', 'styleshop'); however, some people consider it as the topic path name.

$ Path: the path for translating language packs in the template. It is generally stored in the language or lang folder of the template.

For example, in the Styleshop template, load_theme_textdomain () is written in this way. Load_theme_textdomain ('styleshop ', $ template_directory.'/lang '); where $ template_directory is the template path.

If the front-end or back-end of the website is still not displayed in Chinese, check the wp-config.php file under the root directory of the website and find "define ('wplang, and rewrite it to "define ('wplang ', 'zh _ cn');", the website will be displayed as your Chinese language.

If you find that some places are still not perfect when you appreciate your Chinese work, the only reason is that the Poedit software does not find it, or the part to be translated does not use the "_" or "_ e" function. You can use the Dreamweaver software to search for the files in the site directory that need to be written in Chinese. Then, use the "_" or "_ e" function to standardize or directly modify it.

So far, the Chinese tutorial on wordpress template or wordpress plug-in has been completed. If you still find problems during use and still cannot help you out of the predicament, contact the author.

Copyright owned by the Internet, Internet: http://www.olpie.com/

Related Article

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.