Issues with gettext



I have a code to translate my website. For this I’m using the gettext function.
On my own hosting, this code works as it should be, on it doesn’t run.

Anyone idea’s on what is going wrong or what I’m doing wrong?
Below is the code snippet and language files can be found at /inc/locale/de_DE/LC_MESSAGE/

// define constants
define('LOCALE_DIR', PROJECT_DIR .'/locale');
define('DEFAULT_LOCALE', 'de_DE');

$encoding = 'UTF-8';
$locale = (isset($locale))? $locale : DEFAULT_LOCALE;

// gettext setup
echo "locale: ". $locale ."<br>"; //checking the current set locale, for testing purposes
$result = setlocale(LC_MESSAGES, $locale);
    echo "setlocale failed<br>";

// Set the text domain as 'messages'
$domain = 'messages';
$result = bindtextdomain($domain, LOCALE_DIR);
echo "new text domain is set: ". $result ."<br>\n";

// bind_textdomain_codeset is supported only in PHP 4.2.0+
if (function_exists('bind_textdomain_codeset')) {
    $result = bind_textdomain_codeset($domain, $encoding);
    echo "binding: ". $result ."<br>";
$result = textdomain($domain);
echo "Current message domain is: ". $result ."<br>";

echo "<br>Text: ";
echo _("Home");

Thanks in advanced, Ralf


We’re experiencing the same issue that gettext does not work on c9 workspaces, although respective locales are installed.


After many forum and tests, I didn’t manage to get it to work.
it feels like there is a bug/error within the C9 platform.



Someone reached out to me over twitter about this issue, and I asked the following:

  • Is there some kind of error messages that show up? Something in the logs that might let us know what the problem is?
  • When you curl the endpoint from within the workspace, e.g. curl http://localhost:8080/<PATH> do you get the same response as when you visit the application url?

To add to that:

  • Can you let me know how gettext works, and what it needs? Any ideas as to why this doesn’t work on Cloud9 would go a long way in helping us resolve this.
  • If you’re seeing the same code running on another platform, can you verify that the PHP versions are the same, and the server (Apache) is also the same? Any differences between Cloud9 and the working environment may attribute to the issue.




Hey Mutahhir,

thanks for reaching out.
Details about the gettext function can be found here:

The versions of the server it does run correctly on are:
Apache: 2.4.23
PHP: 5.5.38
Running Linux

Hope this helps. If not, please let me know and I will provide the additional details.