gettext

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
mrdebian
Forum Newbie
Posts: 9
Joined: Thu May 10, 2007 4:38 am

gettext

Post by mrdebian »

I'm going mad with this gettext thing....

I followed the tutorial outlined here:
http://mel.melaxis.com/devblog/2005/08/ ... g-gettext/
and did everything exactly as it said but I am not able to switch or even see the text in the 2nd language.

Is there any way to output more information (debug) to see why that happening?
Path and everything else is ok as the poedit parse the files great and creates the po file and its translations without any problem.
I have also restart apache several times without success.

Thanks a lot
mrdebian
Forum Newbie
Posts: 9
Joined: Thu May 10, 2007 4:38 am

Post by mrdebian »

I managed to make it work but cannot switch to languages via the ?locale=en or ?locale=el.

It follows my existing code:

Code: Select all

//$locale = "en";
if (isSet($_GET["locale"])) $locale = $_GET["locale"];
$language = "el";
    putenv("LANGUAGE=$language");
    putenv("LANG=$language");
    setlocale(LC_ALL, $language);
$gettext_domain = 'messages';
bindtextdomain("messages", "./locale");
textdomain("messages");
Any help is much appreciated

Thanks
mrdebian
Forum Newbie
Posts: 9
Joined: Thu May 10, 2007 4:38 am

Post by mrdebian »

I've just found it.
In case that anyone is interested in the proper code is:

Code: Select all

if (isSet($_GET["lang"])) $lang = $_GET["lang"];
//$lang = "el";
    putenv("LANGUAGE=$lang");
    putenv("LANG=$lang");
    setlocale(LC_ALL, $lang);
$domain = 'messages';
bindtextdomain($domain, "./locale");
textdomain($domain);
Post Reply