Skip to content

Instantly share code, notes, and snippets.

@tml tml/gettext example
Created May 20, 2018

Embed
What would you like to do?
locale/en/LC_MESSAGES:
-rw-rw-r-- 1 joey joey 67 May 20 10:38 template.mo
-rw-rw-r-- 1 joey joey 28 May 20 10:37 template.po
template.po:
msgid "foo"
msgstr "foobar"
locale/it/LC_MESSAGES:
total 8
-rw-rw-r-- 1 joey joey 67 May 20 10:38 template.mo
-rw-rw-r-- 1 joey joey 28 May 20 10:37 template.po
template.po:
msgid "foo"
msgstr "barbat"
myscript.php:
<?php
setlocale(LC_ALL, 'en_GB.UTF-8');
bindtextdomain ("template", "./locale");
textdomain ("template");
echo _("foo"), "\n";
setlocale(LC_ALL, 'it_IT.UTF-8');
echo _("foo"), "\n";
php -f myscript.php:
foobar
barbat
@tml

This comment has been minimized.

Copy link
Owner Author

tml commented May 20, 2018

strace -o /dev/stdout -e open -fF php -f myscript.php | grep locale

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.