我正在构建一个使用 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
与 相同的 php 页面http://mywebsite.com/fr/index.php
,但我将检查 url 的语言设置。我希望谷歌将索引该网站的两个版本。
这是一个好方法吗?xml 是否是存储不同语言内容的最佳格式,即使它具有 htmlentity 编码的 html 标签?我有没有忽略什么?