October 5th, 2007

WordPress2.3汉化包不能调用的问题解决

Category: Diary, wordpress, 博言, 推介, Author: 阿七, Popularity: 24% [?]

         WordPress2.3汉化包不能调用的问题解决啦!

刚才在论坛寻求这个问题的答案,发现这几天帖子都没怎么动。不过,运气很好,在聿歆发的帖子:升级2.3后,zh_CN.mo在PHP5以上调用的问题还是没有完美解决 里边找到了答案!

        在浅文 提供的线索:  http://ruleoftech.wordpress.com/ … -language-files-mo/ 里我找到了答案.

原文如下:

         While testing the upcoming WordPress 2.3 I noticed that I had a problem with he localization. Defining the language with WPLANG had no effects and all the text were in English as they should have been in Finnish. I installed another instance of WordPress 2.2.3 and the problem was still there. Somewhat confusing because I had a working WordPress instance with the same PHP-version (php-5.2.4_pre200708051230-r2). The only difference was that the other box was 32-bit system and the other 64-bit. Although at that time I didn’t know what to look for.

         After some googling I found a Spanish-blog which explained the “bug” and provided a solution. Unfortunately I don’t speak Spanish but the solution was clear with pieces of code to show the way. After I knew what to look for I found some discussions about this topic on WordPress Trac and an entry 2 weeks ago with a patch gettext-64-without-bitwise-ops.diff seems to get the thing fixed.

         The problem is in the PHP-gettext which is used for translating strings. The file is located at wp-includes/gettext.php and in that file the problem is created by fixing a bug in PHP 5.0.2 on 64-bit systems. The counterfix is luckily an easy one and you just have to remove some bitwise operators.

           The solution with problematic line on red and the fix on green:

wp-includes/gettext.php line 
115	$this->STREAM = $Reader; 
116	$magic = $this->readint(); 
117    	if ($magic == ($MAGIC1 & 0xFFFFFFFF) || $magic == ($MAGIC3 & 0xFFFFFFFF)) { // to make sure it works for 64-bit platforms 
117	if ($magic == $MAGIC1 || $magic == $MAGIC3) { // to make sure it works for 64-bit platforms 
118		$this->BYTEORDER = 0; 
119	} elseif ($magic == ($MAGIC2 & 0xFFFFFFFF)) { 
120		$this->BYTEORDER = 1;

      ruleoftech 大意是说:他/她也碰到了不能在php5.02的64位的服务器里调用mo语言包,于是在msn search进行了搜索,发现了一个西班牙语博客所解释的”漏洞” ,并提供一个解决办法。
      按照这个方法:解决问题的方法是: 修改wp-includes文件夹下的gettext文件,具体用117行的绿色代码,代替红色代码。或者试用我闲杂修改好的gettext.php文件替代原来的,就能解决中文语言包不能调用的问题,于是后台显示成中文的了。

          我按照这样做了,访问Blog,发现上面的Google广告变成中文的了,我知道一定是成功了!访问后台,果然!

      解决问题啦!
好高兴!

         分享:我修改好的文件,备份你现在的gettext.php文件然后下载我这个文件替代,测试一下:

gettext.rar (3.67 KB)
  我修改好的gettext.php文件

什么?上面的文章不过瘾?我还特意准备了这些:

Tags:, .
评论数量(2) | Add Comments
本文网址:http://blog.designlinks.cn/blogs/wp-2_3-cannot-use-language-files-mo.html

2 Comments so far

» You can leave a response or Trackback .

  1. Gravatar Icon 总而言之,统而言之 Says:

    你的意思是希望集成到中文版里面?这个问题可以考虑一下,多谢:)

    Beach回复:
    我的意思是修改wp-includes文件夹下的gettext文件,或者用修改好的替代,就能解决中文语言包不能调用的问题,于是后台显示成中文的了。

  2. Gravatar Icon 武汉SEO Says:

    边走边看

1 Trackbacks/Pingbacks

leave a reply