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

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
a-bentofreire
Level 2
Level 2
Posts: 82
Joined: Sat Jan 14, 2017 4:02 am

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

Post by a-bentofreire »

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
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
a-bentofreire
Level 2
Level 2
Posts: 82
Joined: Sat Jan 14, 2017 4:02 am

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

Post by a-bentofreire »

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.
Locked

Return to “Software & Applications”