关于在Bluehost上Wordpress中文版变成英文版的解决方案

昨晚突然发现我的wordpress中文版莫名其妙的变成英文版了,查阅一些资料得知:在64位空间上安装wordpress会出不汉化的情况,这是Wordpress自身缺陷,问题的根源原来是Wordpress在64位的CPU下(linux系统)运行时,由于PHP-gettext解析.mo语言文件出错,以至于Wordpress在使用中文版本时失败,这是由于PHP-gettext在加载.mo文件时,没有正确匹配验证位导致stream自动关闭。WordPress 官方还没弄出个最终解决方案,只能自行修改。

步骤如下:

在操作之前,首先确认你安装的Wordpress确实是中文版,然后备份需要修改的文件

1、在\wordpress\wp-includes\这个目录下找到gettext.php

2、打开gettext.php这个文件找到以下代码

  1. if ($magic == ($MAGIC1 & 0xFFFFFFFF)) { // to make sure it works for 64-bit platforms
  2. $this->BYTEORDER = 0;
  3. } elseif ($magic == ($MAGIC2 & 0xFFFFFFFF)) {

3、将上面的代码修改为

  1. if ($magic == $MAGIC1) {
  2. $this->BYTEORDER = 0;
  3. } elseif ($magic == $MAGIC2) {

4、现在重新登陆wordpress,看到是中文就证明成功了,如果还是不行,就将代码修改成

  1. if ($magic == ($MAGIC1 & 0xFFFFFFFF) || ($magic == ($MAGIC3 & 0xFFFFFFFF)) { // to make sure it works for 64-bit platforms
  2.     $this->BYTEORDER = 0;
  3. } elseif ($magic == ($MAGIC2 & 0xFFFFFFFF)) {
  4.     $this->BYTEORDER = 1;
  5. } else {
  6.     $this->BYTEORDER = 0;
  7.     //$this->error = 1; // not MO file
  8.     //return false;
  9. }
  10. ?>

如果再不行的话,我也就没办法了,因为我完成第3步之后就发现已经回到中文版了。

17fav 收藏本文

相关日志

喜欢本文就把我的博客订阅到RSS阅读器吧! 喜欢本文?已经有阳光海,Bruce's blog订阅本博客,如果你想获得阳光海最新的网络联属营销信息可以订阅本博客到你的RSS阅读器。 如何订阅 ?
添加我的博客到 Technorati 收藏 或者添加我的博客到 Technorati 收藏!

“关于在Bluehost上Wordpress中文版变成英文版的解决方案” 有 9 条评论了

  1. Dave 说道:

    Merci beaucoup pour cette solution rapide à ce problème de traduction de langues!

    I found your site, I was having the same problem with my translation in wordpress from english to french, but thanks to your URL, I was able to find your article with the keywords in it :)

  2. Bruce 说道:

    Hi, dave. I am so glad that I can help you for something about wordpress, You are the first foreigner who came to my blog and gave a comment to me. Thanks a lot. :grin:

  3. 枫非寒 说道:

    我晕,折腾一上午才看见这有办法。 :sad:

  4. 菠菜 说道:

    我弄到第二步就搞定了。
    哈哈。。。谢谢Bruce。

  5. 菠菜 说道:

    但是,今天我升级到2.3.2后,又变成英文的了。郁闷

  6. chunfa 说道:

    我用第二种方法成功了,不过要把第10行删除。

  7. Bruce 说道:

    菠菜,那是因为你覆盖了修改过的文件啊。

  8. Dave 说道:

    I’ve found another solution which seems easier, you can find it here: http://bluehostforum.com/showthread.php?t=11536

    ;)

  9. Bruce 说道:

    Dave, thanks so much. That’s really a nice solution about the translation problem about wordpress. :wink:

留下你宝贵的评论吧