/    Sign up×
Community /Pin to ProfileBookmark

Gettext not passing values

Hi,

I have looked through the forum for a fix for this but I was unable to find one.

Basically the code I have provided below is not giving me the correct output in other words changing the text to German.

I am using an “Ubuntu” environment with Apache2 and php5 installed. I have checked that php-gettext is installed.

I have also attached my .mo file [B](I have added the .txt extension to upload here)[/B]

local.php

[code=php]<?php

$locale = false;
if (isSet($_GET[“locale”])){
$locale = $_GET[“locale”];
setcookie(“locale”, $locale, time()+60*60*24*30, “/”);// save a cookie
}
if (!$locale && isSet($_COOKIE[“locale”])){
$locale = $_COOKIE[“locale”];
}
putenv(“LC_ALL=$locale”);//needed on some systems
putenv(“LANGUAGE=$locale”);//needed on some systems
setlocale(LC_ALL, $locale);
bindtextdomain(“messages”, $_SERVER[“DOCUMENT_ROOT”].”locale”);
bind_textdomain_codeset(“messages”, “UTF-8”);
textdomain(“messages”);

?>
[/code]

[code=php]<?php require_once “local.php”;

echo $_SERVER[“DOCUMENT_ROOT”].”locale”; //for testing
?>
<html><head></head>
<body>
<a href=’?locale=en_US’>English</a> |
<a href=’?locale=es_ES’>Spanish</a> |
<a href=’?locale=de_DE’>German</a>
<br>
<?php echo _(“Hello World!”);?><br>
<p><?php echo _(“My name is”);?> Bob.</p>
</body>
</html>
[/code]

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@DasherApr 27.2012 — setlocale function is not a language translator.
Copy linkTweet thisAlerts:
@chrisgukauthorApr 27.2012 — setlocale function is not a language translator.[/QUOTE]

Hi Dasher, I have resolved that issue now I believe, I now have another issue located here, if you are to help then great.

http://www.webdeveloper.com/forum/showthread.php?p=1204640#post1204640

Thanks for your reply!
×

Success!

Help @chrisguk spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...