Skip to content

Instantly share code, notes, and snippets.

Created June 18, 2013 13:00
Show Gist options
  • Save anonymous/5805146 to your computer and use it in GitHub Desktop.
Save anonymous/5805146 to your computer and use it in GitHub Desktop.
PHP gettext testcase
msgid "lab"
msgstr "Labor"
<?php
ini_set('error_reporting', E_ALL);
$d = __DIR__;
if (!is_readable("$d/locale/de_DE/LC_MESSAGES/lab.mo")) {
mkdir("$d/locale/de_DE/LC_MESSAGES", 0755, true);
system("msgfmt -o $d/locale/de_DE/LC_MESSAGES/lab.mo $d/lab.po");
}
putenv('LANGUAGE=de_DE.utf8');
setlocale(LC_MESSAGES, 'de_DE.utf8');
bindtextdomain('lab', "$d/locale");
textdomain('lab');
echo gettext('lab'), "\n\n";
fopen('/some/non-existent/file', 'r');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment