wordpress website

wordpress plugin po mo translation

code

Many wordpress plugins have translation template pot files. We can use Poedit to translate Chinese into Chinese. Generally, plugins or themes will have a languages folder, which is used to store translation files. After normal translation, upload PO and MO files to this. The directory is enough, but sometimes it is invalid after uploading, and it is still in English. At this time, we need to add the following code to any location of the plugin to let wordpress know that I have this translation file here.

 

function my_plugin_init() {
load_plugin_textdomain( 'fusion-builder', false, basename( dirname( __FILE__ ) ) . '/languages/' );
}
add_action('plugins_loaded', 'my_plugin_init');

Note: Only need to modify as follows
fusion-builder is the plugin directory name,
/languages/ is the location where the plugin releases the Chinese files (the default is languages, if not, it needs to be modified)

Leave a Reply