PHP 5.6.11 で Smarty 2.6.28 を使用して、多言語 Web サイトを作成しようとしています。そのために、「smarty-gettext」( https://github.com/smarty-gettext/smarty-gettext ) を使用しようとしています。私の Web サーバーのルート ディレクトリは「/foo」です。
指示に従ってインストールし、「単純に Smarty プラグイン ディレクトリにコピーblock.t.php
しfunction.locale.php
ました」(つまり、「foo/Smarty-2.6.28/libs/plugins」)。
「messages.po」ファイルを含む「foo/locale/de/LC_MESSAGES」ディレクトリを作成しました。
msgid "Hello_World"
msgstr "Hallo Welt!"
これを「messages.mo」ファイルに変換しました。
.php ファイルを作成しました
<?php
putenv('LC_ALL=de');
setlocale(LC_ALL, 'de');
require_once("Smarty-2.6.28/libs/Smarty.class.php");
$smarty = new Smarty();
$smarty->display("test.html");
?>
テンプレート「test.html」を作成しました。
<h1>
{t}Hello_World{/t}
</h1>
ただし、「Hello Welt!」というテキストが表示されます。は表示されず、「Hello_World」のみです。
私は何を間違っていますか?事前にどうもありがとうございました。