[solved] Apache+PHP7.2+Gettext doesn't work on Linux Mint

Questions about applications and software
Forum rules
Before you post please read how to get help
Post Reply
a-bentofreire
Level 1
Level 1
Posts: 37
Joined: Sat Jan 14, 2017 4:02 am

[solved] Apache+PHP7.2+Gettext doesn't work on Linux Mint

Post by a-bentofreire » Sat Oct 20, 2018 9:40 am

Hi,

If I execute this simple example with Apache+PHP+Gettext:
https://github.com/nota-ja/php-gettext-example

Which basically just do this:

Code: Select all

<?php
// I18N support information here
$language = 'en_US';
putenv('LANG=' . $language);
setlocale(LC_ALL, $language);
// Set the text domain as 'messages'
$domain = 'messages';
$localedir = dirname(__FILE__) . '/locale';
echo $localedir . ': ';
bindtextdomain($domain, $localedir);
textdomain($domain);
echo gettext('hello-world') . '<br/>';
?>
- It works on Windows using XAMPP. That is, it displays 'Hello World'.
- It works on shared webhosting solution from a webhosting provider.
- It doesn't work on my local computer with following settings, that is, it display 'hello-world' without any error:

* Linux Mint 19 Tara
* Cinnamon 3.8.9
* PHP Version 7.2.10-0ubuntu0.18.04.1
* Apache/2.4.34 (Ubuntu)
* Gettext module enabled as is displayed on phpinfo()
* mbstring module enabled as is displayed on phpinfo()

To the test I just sudo cp the files to /var/www/html
I tried multiple combinations from the change the files, locales and nothing works on my Linux Mint.

Cheers

a-bentofreire
Level 1
Level 1
Posts: 37
Joined: Sat Jan 14, 2017 4:02 am

Re: [solved] Apache+PHP7.2+Gettext doesn't work on Linux Mint

Post by a-bentofreire » Sun Oct 21, 2018 8:41 pm

After many attempts, I discovered that on my linux mint, it works if I add '.utf8' at the end of the language.
ex: $language = 'en_US.utf8';

On my linux webhosting provider and on XAMPP running on Windows this isn't required.

Post Reply

Return to “Software & Applications”