WordPress and problem with language files (.mo)

September 9, 2007

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; 

The search engines <3

Update, 2008-02-05:
With WordPress 2.3.3 this bug is finally closed with some other minor bug fixes and security fix for xmlrpc.php.

Advertisements

20 Responses to “WordPress and problem with language files (.mo)”


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

  2. twbeta.com Says:

    WordPress 在 PHP5 下的語系問題

  3. Marko Says:

    I haven’t tested the new version of WP in 64-bit environment with the newest PHP but if I recall correctly, the gettext.php is same as before.

  4. Matt Says:

    I can confirm that this bug still exists with WP 2.3.1 and PHP 5.2.3 man, this was aggravating. thanks for the tip!

  5. Nicole Says:

    thanks so much!! this happened to me randomly in wp 2.3 and this post was a lifesaver.


  6. Problem is still there after Versjon 2.3.2….

    This post was a life saver… :P thnx a bunch!

  7. Marko Says:

    This issue seems to be continuing without a proper resolution (gettext.php fixed in WP) although it has been marked as closed in WordPress Trac. The fix is easy but they haven’t from some reasons added it to the release versions of WordPress.

    In the mean time it’s nice to see that this post helps to get things fixed.

  8. thekraken Says:

    Not working for me! I have define (‘WPLANG’, ‘fi’); in wp-config.php and I fixed the line on gettext.php. Nothing changes. Still in english.

  9. thekraken Says:

    Never mind. My mistake. (’WPLANG’, ‘FI_fi’) did the trick. evo.

  10. Tommi Says:

    Thank you for this advice. I was so lost with this same problem and the fix was such an easy one when knowing where to hack.

  11. lpktk Says:

    Thank you! :)


  12. […] Auf 64bit-Servern kam es bei älteren WordPress-Versionen gelegentlich vor, dass das Datum statt in der gewählten Sprache immer noch in Englisch angezeigt wurde. Das Problem ging auf einen Bug in PHP 5 zurück und betraf gettext.php. […]

  13. Manuel Says:

    Thank you very much!!!!!


  14. […] are probably either missing, have the wrong names, or are in the wrong places. Or, it could be this bug in WordPress’s “gettext” functionality, which has to do with whether your web site is running on a computer with a 64-bit processor, or a […]

  15. xbmw Says:

    I`ve resolved the problem! Thanks a lot!

  16. Marko Says:

    It’s nice to see that this post has helped so many.


  17. […] are probably either missing, have the wrong names, or are in the wrong places. Or, it could be this bug in WordPress’s "gettext" functionality, which has to do with whether your web site is running on a computer with a 64-bit processor, or a […]

  18. Christian J Says:

    You saved my day! Been looking at this problem for hours!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: