homepage Welcome to WebmasterWorld Guest from 54.197.15.196
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
gettext and poedit under local xampp
thosecars82

5+ Year Member



 
Msg#: 4114300 posted 1:16 pm on Apr 12, 2010 (gmt 0)

Hello
I have a problem.
Altough I got gettext working under a remote server environment, I have not got it working yet under a local XAMPP installation. I have made sure that gettext is enabled by going to [localhost...] and looking into phpinfo.

The code is really simple:

<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.example.com" );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<?php
$language="es_ES";
putenv("LC_ALL=$language");
setlocale(LC_ALL, $language);
bindtextdomain("messages", "./locale");
textdomain("messages");
print "<p>"._("This website is written in English")."</p>\n";
?>
</body>
</html>


The website display the original string "This website is written in English" instead of translating it into Spanish like it should according to the po file I wrote with poedit.
Any idea?
Thanks

[edited by: eelixduppy at 2:46 pm (utc) on Apr 12, 2010]
[edit reason] exemplified [/edit]

 

thosecars82

5+ Year Member



 
Msg#: 4114300 posted 2:46 pm on Apr 12, 2010 (gmt 0)

Sorry, I made a mistake, the problem is not exactly as I described. The problem is that the text gets always translated into Spanish whether I use
setlocale(LC_ALL, $language) with $language = "es_ES" or with $language="en_GB"

thosecars82

5+ Year Member



 
Msg#: 4114300 posted 11:29 pm on Apr 12, 2010 (gmt 0)

The problem is that I have

<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.example.com" );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<?php
$language="fr_FR";
putenv("LC_ALL=$language");
setlocale(LC_ALL, $language);
bindtextdomain("messages", "./locale");
textdomain("messages");
print "<p>"._("hi! This website is written in English.")."</p>\n";
?>
</body>
</html>

and no matter what string I set the variable $language with that gettext will always look for a translation in the folder locale\es_ES\LC_MESSAGES whether the language is Spanish (es_ES) or not. For example, in the above code, gettext will not look for the French translation as it should in
locale\fr_FR\LC_MESSAGES but it will look for the translation into the folder corresponding to Spanish language, that is to say, locale\es_ES\LC_MESSAGES.

Moreover, if gettext does not find the folder locale\es_ES\LC_MESSAGES then
it will display the string in the original language(English) even if $language equals "fr_FR" and at the same time there is a locale\fr_FR\LC_MESSAGES folder created and the corresponding messages.mo and messages.po files created in this folder.



I made sure that I re-run Apache and MySql under Xampp whenever I change anything in the code but it keeps having this behaviour anyways.

Do you have any idea about why only translations in .po files in the Spanish folder locale\es_ES\LC_MESSAGES are considered and not those translations corresponding to other languages and other folders?

Thanks in advance.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved