gettext translates ALWAYS?


Posted on 16th Feb 2014 07:03 pm by admin

I'm using gettext with the new version of XAMPP (5.3.0) on Windows Seven RTM (build 7600)
gettext-support is enabled.
It used to work perfectly a few weeks ago.
I'm not quite sure what changed this. Be it source changes or the new PHP version.
Now it's translating all the time to Germany although the default-language is English.

To test this, I got 2 files:

gettext.php

Code: <?php
error_reporting(E_ALL);
include("config.inc.php");
echo $locale;
setlocale(LC_ALL, "eng_USA");
echo '
'.gettext('Which data is transferred by the client ?');
?>
localization.php

Code: <?php
$locale = '';

$parameter=explode ( '/' , $_SERVER['REQUEST_URI']);
$locale_change = $parameter[1];

if ($locale_change!=false)
{
if ($locale_change=="de")
{
$locale = "de_DE";
setcookie("locale", $locale, time()+60*60*24*30, "/");// save a cookie
}
else if ($locale_change=="en")
{
$locale = "en_US";
setcookie("locale", $locale, time()+60*60*24*30, "/");// save a cookie
}
}
if (!$locale && isSet($_COOKIE["locale"]))
{
$locale = $_COOKIE["locale"];
}
$locale="en_US";
putenv("LC_ALL=$locale");//needed on some systems
putenv("LANG=$locale");//needed on some systems
putenv("LANGUAGE=$locale");//needed on some systems

bindtextdomain("messages", "./locale/");
bind_textdomain_codeset("messages", 'UTF-8');
textdomain("messages");
?>
The output is always:

en_US
Welche Daten sendet die Client-Software ?

setlocale return false for en_US. If I use the Windows-typical notation "eng_USA" then it returns
English_United States.1252 but the text will be translated to German anyways :/

I have really no clue what's going wrong.

I've put together these test-file and the local files if you want to see yourself what is going wrong. You can download it via www.ali.dj/gettext.zip

No comments posted yet

Your Answer:

Login to answer
302 Like 30 Dislike
Previous forums Next forums
Other forums

PHP Function Page Advice
Hi All, I am quite new to PHP and Javascript but have written an Online Shop (Mainly for Fun and edu

Please Help my PHP Dating Function.
Hi everyone!

Well here is my code that displays this:

It works wonderful.


problem in program for counting no of chars using pointers
Hi all, I was trying to make a program which counts number of chars in a string using concpt of poin

update sql when refresh - php
hi
I have made a table (attachement)

the users can update the sql database using + or x bu

Big O & time complexity ???
can you help me how to calculate the Big O & time complexity for any algorithm and c++ program pleas

weeks in a year
hi,

i found this snippet on php.net
QuoteFor the week number for weeks starting on Sunday:

Filename and Line Number Custom Error
I have a class, with a method that accepts 2 parameters. I would like to output error messages.

Is it possible to put an entire 500-page book in a database with PHP?
I am working on an intranet and I was wondering if its possible to code php with mysql to enter a fu

Lack of simpleXML Documentation
What is up with this.

Look at: http://www.php.net/manual/en/function.simplexml-load-file.php<

FTP issues
Hi all,


I am currently facing some serious problems with a script and really need some ad

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash