前の記事 ≪:mooToolsを使ったクールなウィンドウ作成ライブラリ「Windoo」
次の記事 ≫:ヤフーが形態素解析Webサービスを公開

Zend Frameworkの「Zend_Translate」で多言語対応のサイトを作るチュートリアル

2007年06月19日-はてなブックマーク

スポンサード リンク
[PR] 英単語を忘却曲線アプリを使って超効率よく記憶する方法
Build Multi-lingual Websites With the Zend Framework
I've been lucky enough to have my book, "Beginning PHP and MySQL 5, Second Edition", translated into several languages, among them Chinese, Czechoslovakian, Polish and Russian.

Zend Frameworkの「Zend_Translate」で多言語対応のサイトを作るチュートリアル。
Zend FrameworkにはZend_Translateというクラスが付属しているようで、次のような使い方で多言語対応のサイトが作れます。

<?php
require_once("Zend/Translate.php");

$translate = new Zend_Translate('csv', "it.csv", 'it');
print "<h4>".$translate->_("Table of Contents")."</h4>";
print $translate->_("Chapter 1. An Introduction to PHP")."<br />";
print $translate->_("Chapter 2. Installing Apache and PHP")."<br />";
print $translate->_("Chapter 3. PHP Basics")."<br />";
print $translate->_("Chapter 4. Functions")."<br />";
print $translate->_("Chapter 5. Arrays")."<br />";
?>

別の言語ファイルを CSV で用意しておくことで上記のように簡単なコードで多言語対応できるようです。
覚えておくとよさそうですね。

関連の記事検索:PHP, Web制作, PHPネタ, Zend Framework
スポンサード リンク

By.KJ : 2007年06月19日 10:06 livedoor Readerで購読 Twitterに投稿

間違いの指摘をしていただける方はメール、あるいはTwitter/FBでお願いします(クリック)