本文以wordpress 3.6.1版本为例.
首先,下载WordPress英文版程序,地址为http://wordpress.org/,这里有很多人使用的方法是下载个中文版WordPress,然后安装个英文版的主题而达到前台英文后台中文的目的。这是可以的,但是因为毕竟很多插件都是英文的,还有很多主题对中文不兼容,所以建议还是下载WordPress英文版。
然后下载中文语言包,地址为http://code.google.com/p/wpcn/downloads/list,下载后解压找到zh_CN.mo,把zh_CN.mo文件放到安装了WordPress的网站中wp-content\languages (没有的话自己新建这个文件夹)里。
利用插件实现任意切换的效果。首先下载admin in english博客插件,下载地址为http://wordpress.org/extend/plugins/admin-in-english/ ,下载后,解压,修改里面的admin-in-english.php文件代码,源代码如下
/*
Plugin Name: Admin in English
Plugin URI: http://wordpress.org/extend/plugins/admin-in-english/
Description: Lets you have your backend administration panel in English, even if the rest of your blog is translated into another language.
Version: 1.2.1
Author: Nikolay Bachiyski
Author URI: http://nikolay.bg/
Tags: translation, translations, i18n, admin, english, localization, backend
*/
function admin_in_english_add_hooks() {
add_filter( 'locale', 'admin_in_english_locale' );
}
add_action( 'plugins_loaded', 'admin_in_english_add_hooks' );
function admin_in_english_locale( $locale ) {
if ( admin_in_english_should_use_english() ) {
return 'en_US';//把en_US改为zh_CN
}
return $locale;
}
function admin_in_english_should_use_english() {
// frontend AJAX calls are mistakend for admin calls, because the endpoint is wp-admin/admin-ajax.php
return admin_in_english_is_admin() && !admin_in_english_is_frontend_ajax();
}
function admin_in_english_is_admin() {
return
is_admin() || admin_in_english_is_tiny_mce() || admin_in_english_is_login_page();
}
function admin_in_english_is_frontend_ajax() {
return defined( 'DOING_AJAX' ) && DOING_AJAX && false === strpos( wp_get_referer(), '/wp-admin/' );
}
function admin_in_english_is_tiny_mce() {
return false !== strpos( $_SERVER['REQUEST_URI'], '/wp-includes/js/tinymce/');
}
function admin_in_english_is_login_page() {
return false !== strpos( $_SERVER['REQUEST_URI'], '/wp-login.php' );
}
保存好,压缩成zip文件,在WordPress里上传添加这个插件,如下
启用admin in english插件,后台即可变成中文,前台还是照样不变,登录等字样也是英文,想后台还原为英文的话,只要禁用admin in english插件就行了,这样就大大方便了各位做英文站的童鞋了。