wordpress不能中文化的解决方法。

最近随着WP在各个bloger中越来越流行,偶终于也忍不住了,把原来的Sablog转换成了WP当时由于下载的是www.wordpress.org.cn中文汉化2.3.2版本也打上了他们出的最新mo语言文件,所以就没想这么多直接上传装到了meyu的空间上经过顺利安装后发现中文汉化补丁并不起作用,于是查阅了一些网站发现问题的根源原来是Wordpress在64位的CPU下(linux系统)运行时,由于PHP-gettext解析.mo语言文件出错,以至于Wordpress在使用中文版本时失败。这是由于PHP-gettext在加载.mo文件时,没有正确匹配验证位导致stream自动关闭。

出现此问题的解决方法编辑wp-includes/gettext.php文件,大概在106行左右找到

// $MAGIC1 = (int)0×950412de; //bug in PHP 5.0.2
$MAGIC1 = (int) - 1794895138;
// $MAGIC2 = (int)0xde120495; //bug
$MAGIC2 = (int) - 569244523;
// 64-bit fix
$MAGIC3 = (int) 2500072158;
$this->STREAM = $Reader;
$magic = $this->readint();
if ($magic == ($MAGIC1 & 0xFFFFFFFF) || $magic == ($MAGIC3 & 0xFFFFFFFF)) { // to make sure it works for 64-bit platforms
$this->BYTEORDER = 0;
} elseif ($magic == ($MAGIC2 & 0xFFFFFFFF)) {
$this->BYTEORDER = 1;
} else {
$this->error = 1; // not MO file
return false;
}

替换成:

$this->enable_cache = $enable_cache;// $MAGIC1 = (int)0×950412de; //bug in PHP 5
$MAGIC1 = (int) - 1794895138;
// $MAGIC2 = (int)0xde120495; //bug
$MAGIC2 = (int) - 569244523;
$MAGIC3 = (int) 2500072158; // <- 64 BIT FIX: ADD THIS LINE!
$this->STREAM = $Reader;
$magic = $this->readint();
if ($magic == $MAGIC1 || $magic == $MAGIC3) { // <- 64 BIT FIX: CHANGE THIS LINE!
$this->BYTEORDER = 0;
} elseif ($magic == $MAGIC2) {
$this->BYTEORDER = 1;
} else {
$this->error = 1; // not MO file
return false;
}

发表评论