在PHP中支持多语言的最佳系统? [英] Best system for multiple language support in PHP?
问题描述
我有一个要本地化的PHP应用程序.目前,我这样做的方式非常丑陋:$ loc ['hello'] ="Hello",echo $ loc ['hello'];将显示Hello,您可以更改文件以更改语言.我正在考虑的是一种更好的方法,并且执行起来更快,这是我正在考虑的:
I have an PHP application that I want localized. Currently, the way I'm doing this is a very ugly way: $loc['hello'] = "Hello", echo $loc['hello']; will show Hello, and you can change the file to change the language. What I want is a better way and a faster of doing this, what I'm considering:
- 1个XML文件,其中包含所有页面的语言数据(速度会很慢,因为每个页面都会加载整个网站的语言数据)
- 多个文件,每个页面一个xml文件(帮助不大,因为它和旧系统一样混乱)
- gettext()(这似乎是最好的方法,但是我今天才发现它,所以很难从当前的系统更改为这个系统吗?快吗?)
因此,总结一下,从我当前的方法到新方法,最快,最干净,最容易的方法是哪种.谢谢.
So to summarize, which way is the fastest, the cleanest, and the easiest to move from my current way to the new one. Thanks.
推荐答案
类似问题:
- what is the best method to build "multilingual" script in php?
- Programming Multi-Language PHP applications
Here's a benchmark comparing gettext with string-array: Benchmarking PHP Localization - Is gettext fast enough?
这篇关于在PHP中支持多语言的最佳系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!