I'm at a loss of what I'm doing wrong. Gettext is enabled, according to phpinfo(). I have checked out the locales that the system uses and generated the danish ones, so the language alias exists in the system.
I don't know if I have set things up right in the php file shown below:
<?php
// I18N support information here
$language = "da_DK.utf8";
$p = putenv("LANG=" . $language);
echo 'pputenv: '.$p;
echo "<br>";
echo "<br>";
$s = setlocale(LC_ALL, $language);
echo 'setlocale: '.$s;
echo "<br>";
echo "<br>";
// Set the text domain as "messages"
$domain = "messages";
$b = bindtextdomain($domain, "Locale");
echo 'bindtextdomain: '.$b;
echo "<br>";
echo "<br>";
$b2 = bind_textdomain_codeset($domain, 'UTF-8');
echo 'bind_textdomain_codeset: '.$b2;
echo "<br>";
echo "<br>";
$t = textdomain($domain);
echo 'textdomain: '.$t;
echo "<br>";
echo "<br>";
if (!function_exists("gettext"))
{
echo "gettext is not installed\n";
}
else
{
echo "gettext is supported\n";
}
echo "<br><br>";
//phpinfo();
echo _("HELLO_WORLD").'<br>';
echo _('Testing Translation...').'<br>';
?>
The result I get from that file is:
pputenv: 1
setlocale: da_DK.utf8
bindtextdomain: /var/www/sites/interna/Locale
bind_textdomain_codeset: UTF-8
textdomain: messages
gettext is supported
HELLO_WORLD
Testing Translation...
Lastly, this is the .po file use for the danish translation:
msgid ""
msgstr ""
"Project-Id-Version: danish interna\n"
"POT-Creation-Date: 2014-07-08 15:32+0100\n"
"PO-Revision-Date: 2014-07-08 15:32+0100\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: Danish\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.5.4\n"
"X-Poedit-KeywordsList: _;gettext;gettext_noop\n"
"X-Poedit-Basepath: .\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-SearchPath-0: ../..\n"
#: ../../index.php:49
msgid "HELLO_WORLD"
msgstr "Hej verden"
#: ../../index.php:50
msgid "Testing Translation..."
msgstr "Tester"
Can someone help?