views:

276

answers:

3

I followed the folling tutorial: http://mel.melaxis.com/devblog/2005/08/06/localizing-php-web-sites-using-gettext/

about Php gettext extension (I unchecked the comment in the php.ini)

The gettext is activated but it doesn't show up the translation (German).

Here are the files:

C:\wamp\www\php-test\test.php:

<?php
require_once("localization.php");
echo _("Hello World!");
?>

C:\wamp\www\php-test\localization.php:

<?php
$locale = "de_DE";
if (isSet($_GET["locale"])) $locale = $_GET["locale"];
putenv("LC_ALL=$locale");
setlocale(LC_ALL, $locale);
bindtextdomain("messages", "./locale");
textdomain("messages");
?>

C:\wamp\www\php-test\locale\de_DE\LC_MESSAGES\messages.po:

msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2010-02-14 00:35+0800\n"
"PO-Revision-Date: 2010-02-14 00:37+0800\n"
"Last-Translator: Jano Chen <[email protected]>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-KeywordsList: _;gettext;gettext_noop\n"
"X-Poedit-Basepath: C:\\wamp\\www\\php-test\n"
"X-Poedit-Language: German\n"
"X-Poedit-Country: GERMANY\n"
"X-Poedit-SourceCharset: iso-8859-1\n"
"X-Poedit-SearchPath-0: .\n"

#: test.php:2
msgid "Hello World!"
msgstr "Hallo Welt!"

C:\wamp\www\php-test\locale\de_DE\LC_MESSAGES\messages.mo

(sorry from some reason I can't copy the text of this file)

alt text

When I open it should display "Hallo Welt" (Hello World in German) but instead it displays it in English (Hello World).

Any suggestions?

PS: I'm using Windows XP SP2

A: 

as stated in the manual page for setlocale (did you read it?), windows uses different language/country/region strings. try adding them to your de_DE, like so (also from the man page):

setlocale(LC_ALL, 'de_DE', 'deu_deu');

see also the warning on locale information being maintained per process.

ax
It didn't work, I think the php setlocale is right. I checked at http://msdn.microsoft.com/en-us/library/dd318693%28VS.85%29.aspx and the locale string its de_DE.
janoChen
+1  A: 

I was using Wamp Server 2 (i), I uninstalled it and used Wamp Server 2 (c), and it fixed the problem. Weird.

janoChen
A: 

@janoChen:

Trying the same, but I don't know how to create the po-file? How did you manage this? POEdit is a program that should do this but I have succeeded trying it.

tobefound