0
votes

It will now make many weeks it try to make it work but it doesn't on Ubuntu. (even though it works on localhost...)

Here is the PHP code where the selection of the language is made. This code is in the following path : /srv/d_disk/www/www.domaine.com/htdocs/www/mainsite/index.php

putenv("LANG=$langage");
$directory = dirname(__FILE__).'/locale';

$domain = 'traductions';
$locale=$langage . '.utf8';

setlocale( LC_MESSAGES, $locale);
bindtextdomain($domain, $directory);
textdomain($domain);
bind_textdomain_codeset($domain, 'UTF-8');

The variable $langage is filled in by either : fr_FR, or en_US (i did an echo and it changed correctly) but language doesn't change on screen.

the locale -a gives shows me that the locale fr_FR.utf8 and fr_FR are installed (same for en_US) the .po and .mo can be found here : /srv/d_disk/www/www.domaine.com/htdocs/mainsite/locale/fr_FR.utf8/LC_MESSAGES

i recompiled the .po files with : msgfmt -o traductions.mo -v traductions.po

the .po file is the following :

msgid ""
msgstr ""
"Project-Id-Version: test\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-11-17 19:41+0100\n"
"PO-Revision-Date: 2011-11-22 20:45+0100\n"
"Last-Translator: \n"  
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-KeywordsList: _;gettext;gettext_noop;{t}\n"
"X-Poedit-Basepath: ../../../mainsite/presentation/templates\n"
"X-Poedit-SourceCharset: utf-8\n"
"X-Poedit-SearchPath-0:    /srv/d_disk/www/www.domaine.com/htdocs/mainsite/presentation/templates\n"
"X-Poedit-SearchPath-1: ../../../mainsite/presentation/templates\n"

#: /srv/d_disk/www/www.domaine.com/htdocs/mainsite/presentation/templates/about-us.c:1
msgid "About Us"
msgstr "A Propos de Nous"

but nothing changed...

In phpinfo, i have the label that GETTEXT support is enabled.

An idea ?

EDIT : By using strace i get the following =>

PHP Warning:  PHP Startup: Unable to load dynamic library
'/usr/lib/php5/20090626+lfs/gettext.so' - /usr/lib/php5/20090626+lfs/gettext.so: 
cannot open shared object file: No such file or directory in Unknown on line 0
Bienvenue<br />Bonne journ?e<br />   

EDIT 2 : By removing the gettext.so, i have the following when using strace : strace -e trace=file -o test.txt php test_hasher.php Bienvenue
Bonne journ?e


Which means it's translated in French in strace but NOT when recharhing the page (even after cache cleanup and restart of apache)

1
Why does your .po file starts with msgid "" msgstr ""?hakre
I don't know. I have just delete these two lines and restarted apache but it didn't help.paul P
I rebooted the server so i guess it's not linked to cache.paul P
Is the code you've given being ran before you try to use the gettext functions like _()?dsas

1 Answers

0
votes

What happens if you change the locale dir to /srv/d_disk/www/www.domaine.com/htdocs/mainsite/locale/fr_FR/LC_MESSAGES ? i.e. removing the ".utf8"