Language translation in wordpress (tips)

Its important to think of language translation when creating plugins, hence http://codex.wordpress.org/Translating_WordPress is important. Use __ or _e whenever possible.

I strongly recommend poedit for text translation. In poedit, open an existing language file and save it again under your locale but named differently eg woocommerce-zh_AU.po – see http://codex.wordpress.org/WordPress_in_Your_Language. 2 files will be created, ie .mo and .po in the default plugin directory. The trick though is not to save them in the plugin directory or else it is possible that your files could be gone upon plugin updates. Where do you save it then? save it in /wp-content/languages/{plugin_name}/{translated_file}, in my example, it will be /wp-content/languages/woocommerce/woocommerce-zh_AU.po and woocommerce-zh_AU.mo

Next, define your new locale in wp-config.php


// how about some australian chinese
define ('WPLANG', 'zh_AU');

All done.

Like it.? Share it:
Tags:

Comments are closed.