This post is on internationalization, specifically for the Chinese subsite. Those who have been following along will know that I have a custom post type for newsletters, and that this is displaying a link to the PDF file to be downloaded by getting the URL from the _wp_attached_file meta value. For the English version, it displays some text before the link (“Download MM: “). Obviously, this text should be in Chinese for the Chinese subsite. Looks like internationalization is a good way to achieve this.
Declare Theme Text Domain
Put this on top of the functions.php file.
load_theme_textdomain('theme_name', STYLESHEETPATH . '/languages');
Mark String as Translatable
The next step is to mark the ‘Download MM’ string as something to be translated. This is done by putting it in a special function __()
__( 'Download MM', 'theme_name' )
This is a program which will get all the translatable strings out of the source code and create a .po file. It also provides an interface for supplying the translation and automatically generates the .mo file.
The final step is to copy the .po and .mo files to the theme’s languages folder (newly created). It is also necessary to rename them to zh_CN.mo and zh_CN.po so that the translated string would get picked up correctly.
The link on the WordPress Codex to the guides on the Urban Giraffe are excellent.