【发布时间】:2009-03-27 19:40:03
【问题描述】:
我正在构建一个使用 LAMP 和 Smarty 模板框架的 Web 应用程序。该网站将有大量静态内容(关于我们的页面、错误警报、确认电子邮件等......)。
Web 应用程序必须支持多种语言。以下方法合适吗?
1) Smarty 模板页面(html 页面)上的所有静态副本都将替换为对 smarty 插件的调用,例如 {lang file='about.xml' getTerm='title'} ,它返回一个字符串作为标题标签合适的语言
2) about.xml 文件是网络服务器上的一个 xml 文档,充当多语言词典。所以它会有xml节点比如
<term value="title">
<en><a href="http://stackoverflow.com"&rt;Stackoverflow</a&rt; is a great site</en>
<fr><a href="http://stackoverflow.com"&rt;Stackoverflow</a&rt; c'est website magnifique</fr>
<ch><a href="http://stackoverflow.com"&rt;Stackoverflow</a&rt; complex looking chinese characters I don't udnerstand</ch>
</term>
<term value="signupmessage">
<en><a href="http://stackoverflow.com"&rt;Stackoverflow</a&rt; great deals!</en>
<fr><a href="http://stackoverflow.com"&rt;Stackoverflow</a&rt; magnifique deals!</fr>
<ch><a href="http://stackoverflow.com"&rt;Stackoverflow</a&rt; complex looking chinese characters I don't udnerstand</ch>
</term>
3) 网站的 url 结构将是 http://mywebsite.com/language/index.php。为此,我的网络服务器将具有符号链接,例如
ln -s ./en ./ 以便 http://mywebsite.com/en/index.php 指向与 http://mywebsite.com/fr/index.php 相同的 php 页面,但我会检查 url 的语言设置。我希望谷歌能索引网站的两个版本。
这是一个好方法吗? xml 是存储不同语言内容的最佳格式,即使它具有 htmlentity 编码的 html 标签?我忽略了什么吗?
【问题讨论】:
标签: php smarty multilingual