Page 1 of 1

Problem with the gettext.....

Posted: Wed Jun 27, 2007 10:59 am
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]

Posted: Wed Jun 27, 2007 11:01 am
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?

Posted: Fri Jun 29, 2007 5:32 am
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.

Posted: Fri Jun 29, 2007 10:08 am
by superdezign
Try escaping the slashes in the path:

Code: Select all

$locale_dir = 'C:\\Program Files\\xampp\\htdocs\\test\\locale\\';

Posted: Fri Jun 29, 2007 11:53 am
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.