October 5th, 2007


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


刚才在论坛寻求这个问题的答案,发现这几天帖子都没怎么动。不过,运气很好,在聿歆发的帖子:升级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文件替代原来的,就能解决中文语言包不能调用的问题,于是后台显示成中文的了。




gettext.rar (3.67 KB)


Tags:, .
评论数量(2) | Add Comments

2 Comments so far

» You can leave a response or Trackback .

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



  2. Gravatar Icon 武汉SEO Says:


1 Trackbacks/Pingbacks

leave a reply