Gettext doesn't work on WAMP 64 Bits
Posted by: jmeile (---.ethz.ch)
Date: January 07, 2014 11:03AM

Hi,

I just think this is worth of posting: gettext won't work when you install the 64 Bits version of WAMP. I lost three days trying to figure out this. Actually I tested with:
* WampServer: 2.4 / 64 bits
* Apache Version: 2.4.4
* PHP Version: 5.4.12
* OS: Windows 7 / 64 bits

And this is the code, which works with the 32 bits version:

define('LOCALE_DIR', '<root_dir_of_your_po_files>'); //ie: C:/wamp/www/your_app/locale
$locale = '<your_locale>'; //ie: es_CO
$domain = 'your_gettext_domain'; //ie: messages
putenv('LC_ALL=' . $locale);
bindtextdomain($domain, LOCALE_DIR);
textdomain($domain);
echo _('<your_string>'; // ie: Hello world


However with the 64 Bit version, it will use the systems locale, which on my case it is German (Switzerland).

I tried several versions of the code, which I found on several forums and realized that on windows you don't really need to call "setlocale" nor to set the LANG, LANGUAGE, and LC_MESSAGES environment variables. It is enough with the "LC_ALL" variable. "setlocale" will always failed unless you include a Windows like locale, ie: "Esp_Col", "Spanish_Colombia", or "Spanish_Col". Anyway, since it works without "setlocale", I just dropped that line.

I'm just wondering if this is a problem of apache 64 Bit for windows or it is really related to WAMP.

For the french speakers, I also found a reference to this problem on the french forum:
[forum.wampserver.com]

Best regards
Josef



Edited 3 time(s). Last edit at 01/07/2014 11:10AM by jmeile.

Re: Gettext doesn't work on WAMP 64 Bits
Posted by: lenamtl (---.139-37-24.static.videotron.ca)
Date: January 10, 2014 06:49PM

Hi,


Do you mind to share your code

Thanks



Edited 2 time(s). Last edit at 01/10/2014 07:10PM by lenamtl.

Re: Gettext doesn't work on WAMP 64 Bits
Posted by: jmeile (---.dclient.hispeed.ch)
Date: January 12, 2014 08:42AM

Hi,

The code is on the original post. Please read it carefully. You just have to replace the following by your own:
* <root_dir_of_your_po_files>: Folder where your translated messages are located
* <your_locale>: Language that you want to test
* your_gettext_domain: gettext domain of your translations
* <your_string>: Message you want to translate

Off course, you will need your own po-file and compile it into .mo.

As I said, the code works in the 32 Bits version, but not in the 64 Bits. I guess it is related to multi thread.

Best regards
Josef



Edited 2 time(s). Last edit at 01/12/2014 08:45AM by jmeile.

Re: Gettext doesn't work on WAMP 64 Bits
Posted by: stevenmartin99 (Moderator)
Date: January 12, 2014 08:48AM

Use this get text independent project, php64 has a long way to go before issues are aorted.

[bazaar.launchpad.net]

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Re: Gettext doesn't work on WAMP 64 Bits
Posted by: jmeile (---.ethz.ch)
Date: January 13, 2014 09:23AM

Dear Steven

Thanks for your advise. I just decided to keep working with WAMP 32 Bits. Now I'm using gettext + PHPTal.
If I see the need of using the 64 Bit version, then I will consider using that library.

The only problem with PHPTal is that linux and Windows have a different locale management: linux uses locales like 'en_US', but windows expects 'English_United States'. Anyway, I just did a locale mapping table to cope with this, ie:

locale | win_local
en_US | English_United States
de_CH | German_Switzerland
es_CO | Spanish_Colombia

If you don't want to use PHPTal, then you won't have the locale problem. gettext under Windows + WAMP 32 Bits will perfectly understand this:
putenv('LC_ALL=en_US');

I know also that with PHPTal you can use another library for translating your messages and it isn't difficult to implement this; however for now I will stick with the standard library.


Best regards
Josef

Sorry, only registered users may post in this forum.