I'm following the tutorial here, php is outputting the msgid instead of the msgstr. Here is what I have...
extension=php_gettext.dll
uncommented in php.ini
(this was already uncommented in xampp)
php_gettext.dll
in C:\xampp\php\ext
(this was already in xampp)
Directory structure C:\xampp\htdocs\TestI18N\Locale\en_US\LC_MESSAGES
with created messages.po
and messages.mo
files in LC_MESSAGES
.
A file called test-locale.php
in C:\xampp\htdocs\TestI18N
with the following
// I18N support information here
$language = "en_US";
putenv("LANG=" . $language);
setlocale(LC_ALL, $language);
// Set the text domain as "messages"
$domain = "messages";
bindtextdomain($domain, "Locale");
bind_textdomain_codeset($domain, 'UTF-8');
textdomain($domain);
echo _("HELLO_WORLD");
My messages.po
file
msgid ""
msgstr ""
"Project-Id-Version: TestProject
"
"POT-Creation-Date: 2017-08-22 23:42+0300
"
"PO-Revision-Date: 2017-08-22 23:53+0300
"
"Last-Translator:
"
"Language-Team: English
"
"MIME-Version: 1.0
"
"Content-Type: text/plain; charset=UTF-8
"
"Content-Transfer-Encoding: 8bit
"
"X-Generator: Poedit 2.0.3
"
"X-Poedit-Basepath: .
"
"Plural-Forms: nplurals=2; plural=(n != 1);
"
"Language: en_US
"
"X-Poedit-SourceCharset: UTF-8
"
# Test token 1
msgid "HELLO_WORLD"
msgstr "Hello World!"
# Test token 2
msgid "TEST_TRANSLATION"
msgstr "Testing translation..."
The output is HELLO_WORLD
. What am I doing wrong? Thanks.