PHP中多语言支持的最佳系统?

时间:2022-07-04 15:20:45

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:

我有一个我想要本地化的PHP应用程序。目前,我这样做的方式非常难看:$ loc ['hello'] =“Hello”,echo $ loc ['hello'];将显示Hello,您可以更改文件以更改语言。我想要的是一种更好的方式,更快地做到这一点,我正在考虑的事情:

  • 1 XML file with language data for all page (will it be slow as every page will load the language data for the entire site)
  • 1个包含所有页面语言数据的XML文件(因为每个页面都会加载整个站点的语言数据,所以会很慢)

  • Multiple files, one xml file for each page (not much help as it is just as messy as the old system)
  • 多个文件,每个页面一个xml文件(没有多大帮助,因为它与旧系统一样混乱)

  • gettext() (This seem to be the best way, but I only discovered it today, so will it be hard to change from my current system to this? Is it fast?)
  • 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.

总而言之,哪种方式是最快,最干净,最容易从我现在的方式转移到新的方式。谢谢。

2 个解决方案

#1


3  

Similar Questions:

Here's a benchmark comparing gettext with string-array: Benchmarking PHP Localization - Is gettext fast enough?

这是一个比较gettext和string-array的基准:基准测试PHP本地化 - gettext足够快吗?

#2


0  

A PHP array like the one you already have is pretty fast and clean in my opinion.

在我看来,像你已经拥有的PHP数组非常快速和干净。

Localization itself is ugly to code and manage changes so don't expect that there is a method to make all the pain go away.

本地化本身很难编码和管理变更,因此不要指望有一种方法可以消除所有的痛苦。

#1


3  

Similar Questions:

Here's a benchmark comparing gettext with string-array: Benchmarking PHP Localization - Is gettext fast enough?

这是一个比较gettext和string-array的基准:基准测试PHP本地化 - gettext足够快吗?

#2


0  

A PHP array like the one you already have is pretty fast and clean in my opinion.

在我看来,像你已经拥有的PHP数组非常快速和干净。

Localization itself is ugly to code and manage changes so don't expect that there is a method to make all the pain go away.

本地化本身很难编码和管理变更,因此不要指望有一种方法可以消除所有的痛苦。