Problem with the gettext.....

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
amardhuri
Forum Newbie
Posts: 3
Joined: Tue Jun 26, 2007 9:00 am

Problem with the gettext.....

Post by amardhuri »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi,

i am trying to use the gettext function in PHP i have downloaded the php_gettext.dll file and php_iconv.dll 


Here are my php.ini details.

extension_dir=C:\Program Files\xampp\php\ext\

this directory contains above two dll files.

these two lines are uncommented from the ini file.

extension=php_gettext.dll
extension=php_iconv.dll

locale path

C:\Program Files\xampp\test\locale

here is the locale directory structure

      fr
          LC_MESSAGES
                                 messages.mo
                                 messages.po


Here is the php code

Code: Select all

<?

$locale = 'fr'; // Pretend this came from the Accept-Language header
$locale_dir = 'C:\Program Files\xampp\htdocs\test\locale\\'; 

putenv("LANGUAGE=$locale");
putenv("LANG=$locale");
bindtextdomain('messages', $locale_dir);
textdomain('messages');

echo gettext("This is my first gettext text......") ;

?>

But i dont know why it is not translating the text in french it is displaying as it is in english.

Can anyone know where m i wrong?

Why it is not translating the text?

Thanks

Regards.


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

If the function doesn't give you an error saying it's undefined, then it's not your php.ini. Are you sure you read the documentation correctly?
amardhuri
Forum Newbie
Posts: 3
Joined: Tue Jun 26, 2007 9:00 am

Post by amardhuri »

yes i have read the documentation correctly and it is not showing any error like undefined .

I have did the things as it was in the documentation .

but dont know why it is not translating the text.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Try escaping the slashes in the path:

Code: Select all

$locale_dir = 'C:\\Program Files\\xampp\\htdocs\\test\\locale\\';
amardhuri
Forum Newbie
Posts: 3
Joined: Tue Jun 26, 2007 9:00 am

Post by amardhuri »

No..... same thing it is not translating the text.

Is there any thing with the .po or .mo files because the locale folder i have downloaded from the net if there is something with these two files please tell me.
Post Reply