Problem with gettext() and POEdit

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Gingi
Forum Newbie
Posts: 1
Joined: Sat Apr 10, 2010 5:32 am

Problem with gettext() and POEdit

Post by Gingi »

Hi everyone,
my problem is the following: I've recently learned how to internationnalize my website using .mo files. I think that I've done everything good and the fact is that my page is translated but in one language only :? Whatever the link I click on, it keeps showing the text in French (which is not normal). I've restarded my server like a zillion times and nothing's changed.

That's how my site looks like:
.local\page.php
.local\fr_FR\LC_MESSAGES\default.mo
.local\en_EN\LC_MESSAGES\default.mo

And this is the code of my "page.php":

Code: Select all

<?php
if (!empty($_GET['lang'])) {
	switch ($_GET['lang']) { 
		case 'fr':
			$langage = 'fr_FR';
			break;
		case 'en':
			$langage = 'en_EN';
			break;
		case 'de':
			$langage = 'de_DE';
			break;
		default:
			$langage = 'en_EN';
			break;
	}
	
	putenv("LANG=$langage"); 
	setlocale(LC_ALL, $langage); 
	
	$nomDesFichiersDeLangue = 'default'; // File .mo
	
	bindtextdomain($nomDesFichiersDeLangue, "C:\wamp\www\local"); 
	textdomain($nomDesFichiersDeLangue);t
	
	
	echo gettext('Welcome !');
	echo '<br >';
	echo _('Goodbyer !');
	echo _('Ciao !');
	echo '<br /><br />';
}


echo '<a href="page.php?lang=fr">français</a><br />';
echo '<a href="page.php?lang=en">english</a><br />';
echo '<a href="page.php?lang=de">deutsch</a><br />';
?>

If you have experienced the same think, please share :wink: This thing is driving me crazy.
Thanks a lot.
Post Reply