gettext , , .
- "" .
-
echo _("Hello, world!");
( % s, printf)
french
msgid "Hello, world!"
msgstr "Salut, monde!"
msgid "My name is %s"
msgstr "Mon nom est %s"
italian
msgid "Hello, world!"
msgstr "Ciao, mondo!"
msgid "My name is %s"
msgstr "Il mio nome è %s"
,
- gettext (gettext(), ngettext(), _())
- xgettext (* nix) php .po.
- poedit, .po.
- msgfmt (* nix) .mo .po
- .mo ,
/de_DE/LC_MESSAGES/myPHPApp.mo
/en_EN/LC_MESSAGES/myPHPApp.mo
/it_IT/LC_MESSAGES/myPHPApp.mo
, php script, ,
php
<?php
setlocale(LC_ALL, 'de_DE');
bindtextdomain("myPHPApp", "./locale");
textdomain("myPHPApp");
echo gettext("Welcome to My PHP Application");
echo _("Have a nice day");
?>
php