get text
PHP を使用して、Web サイトに多言語サポートを追加しようとしています。これまでのところ失敗しており、その理由はわかりません。
私のi18n.php
ファイルにはこれがあります:
<?php
$locale = 'pt_PT.utf8';
$locale_dir = './locale';
$domain = 'messages';
setlocale(LC_ALL, $locale);
putenv("LANG=$locale");
putenv("LANGUAGE=$locale");
bindtextdomain($domain, $locale_dir);
bind_textdomain_codeset($domain, 'UTF-8');
textdomain($domain);
?>
次に、で./locale/pt_PT.utf8/LC_MESSAGES/messages.po
:
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-11-23 20:31+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: pt_PT.utf8\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: index.php:12
msgid "E-mail"
msgstr "Endereço electrónico"
#: index.php:13
msgid "Password"
msgstr "Palavra-chave"
#: index.php:14
msgid "Password (again)"
msgstr "Palavra-chave (novamente)"
#: index.php:15
msgid "Login"
msgstr "Entrar"
次に、ファイルを生成し.mo
ます。
msgfmt -o ./locale/pt_PT.utf8/LC_MESSAGES/messages.mo ./locale/pt_PT.utf8/LC_MESSAGES/messages.po
PHP では、Linux システムにロケールがインストールされている必要があるようですlocale -a
。
C
C.UTF-8
de_AT.utf8
...
en_AG
...
es_AR.utf8
...
POSIX
pt_BR.utf8
pt_PT.utf8
...
i18n.php
ファイルへの最初のインクルードindex.php
ですが、メッセージは表示されません。私が見逃しているものはありますか?