如何构建具有多种语言支持(英语,法语,中文等)的PHP应用程序 [英] How to build PHP application with multiple language support (English, French, Chinese etc..)

查看:69
本文介绍了如何构建具有多种语言支持(英语,法语,中文等)的PHP应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个使用LAMP和Smarty模板框架的Web应用程序.该网站将包含大量静态内容(关于我们的页面,错误警报,确认电子邮件等).

I'm building a web application that uses LAMP and the Smarty template framework. The website will have plenty of static content (about us page, error alerts, confirmation emails etc...).

该Web应用程序必须支持多种语言.以下方法合适吗?

The web application must support multiple languages. Is the following approach appropriate?

1)Smarty模板页面(html页面)上的所有静态副本将被对Smarty插件的调用所取代,例如{lang file ='about.xml'getTerm ='title'},该插件会返回标题标签中的字符串适当的语言

1) All static copy on Smarty template pages (html pages) will be replaced by calls to smarty plugins such as {lang file='about.xml' getTerm='title'} which returns a string for the title tag in the appropriate language

2)文件about.xml是Web服务器上的xml文档,用作多语言词典.因此它将有xml节点,例如

2) The file about.xml is an xml document on the webserver that acts as a multiple language dictionary. So it will have xml nodes such as

<term value="title">
   <en>&lt;a href=&quot;http://stackoverflow.com&quot;&rt;Stackoverflow&lt;/a&rt; is a great site</en>
   <fr>&lt;a href=&quot;http://stackoverflow.com&quot;&rt;Stackoverflow&lt;/a&rt; c'est website magnifique</fr>
   <ch>&lt;a href=&quot;http://stackoverflow.com&quot;&rt;Stackoverflow&lt;/a&rt; complex looking chinese characters I don't udnerstand</ch>
</term>
<term value="signupmessage">
   <en>&lt;a href=&quot;http://stackoverflow.com&quot;&rt;Stackoverflow&lt;/a&rt; great deals!</en>
   <fr>&lt;a href=&quot;http://stackoverflow.com&quot;&rt;Stackoverflow&lt;/a&rt; magnifique deals!</fr>
   <ch>&lt;a href=&quot;http://stackoverflow.com&quot;&rt;Stackoverflow&lt;/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的语言设置.我希望Google可以为该网站的两个版本编制索引.

3) The url structure for the site will be http://mywebsite.com/language/index.php. To do this, my webserver will have symbolic links such as ln -s ./en ./ so that http://mywebsite.com/en/index.php points to the same php page as http://mywebsite.com/fr/index.php, but I will check the url for language settings. My hope is that google will index both versions of the site.

这是一个好方法吗?即使xml具有htmlentity编码的html标签,xml还是存储不同语言内容的最佳格式吗?我有什么事吗?

Is this a good approach? Is xml the best format for storing content of different languages even though it has htmlentity encoded html tags? Did I overlook anything?

推荐答案

不确定您的问题的详细信息,但您可能想看看

Not sure about the details of your question but you may want to take a look at Zend_Translate.

这篇关于如何构建具有多种语言支持(英语,法语,中文等)的PHP应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆