WordPress plug-ins \ themes localization
Once you plug programming has ended, another area worth considering is how to plug your internationalization (of course, this is built on your work you want to release to the public on the premise). "Internationalize" is a building of your software so that the process can be localized; and "localize" the software is to show you the text translated into various languages process. WordPress has been from all over the world to use each of the local fans, so it will internationalization and localization features into its structure, including localization features plug-ins. Would like to learn more about the GNU gettext localization of background knowledge, please refer to translation of WordPress.
Strongly recommend that you plug your internationalization, so that the user name from all corners of the country can localize it. And this whole process is very straightforward:
- Give you a translation of the plug-election to "text domain" name. This is generally the same file name of your plug-ins the same, of course, does not include. Php suffix names, and must be unique, at least not with the user has to ensure that the installation of other plug-ins of the same name.
- Regardless of any time you want to use plug-ins to display text to the web page readers (that is, "Information text"), are embedded in them as much as possible the following two procedures WordPress gettext function of any paragraph. Remember, unlike the core WordPress code, in your plug-in function in the internationalization of you should use the second parameter to pass the text of your choice domain. While in the core WordPress code, this parameter is empty by default.
__ () Used to message as a parameter to another function. _e () used to write directly to the message page.
- __ ($ message, $ domain): the localization of the language used for $ domain translation $ message. The output string can continue by other function call.
- _e ($ message, $ domain): the localization of the language used for $ domain translation $ message, then display to the user's screen. If your text will be directly displayed to the reader, you can use this function.
- For your plug-ins to create a POT file (this one included all the text of Article translation entry documents), with the release of your plug-ins. Plug create a user will need a good translation localization MO file, and then you put it in the same plug-ins folders. Mo file and this is also about the name, it should be as domain-ll_CC.mo, here is the local national and ll_CC language code (for example, zh_CN). With reference to translation of WordPress more on POT files, MO files and localized information.
- In your plug-ins to add a subroutine to call load_plugin_textdomain plug your translation. This subroutine must be in front of your gettext function, but it was later the better (because some multi-language plug-in calls will change some of the geographical settings). One possible way is to plug in all your routines in front of an initial increase in Subroutine. For example, suppose you the text of the domain name "fabfunc", are:












































