I want to make a site available in three languages, in my knowledge I can use three way to achieve this.

  1. With .po and .mo file like wordpress.
  2. With php array dumping in html file.
  3. With storing a labels in database.

    The database may be increase with large amount of data.

My Question is what is the fastest and better way for translating site labels in these three options.

Thanks in advance.

有帮助吗?

解决方案

  1. gettext (using .po and .mo files) is the classic, stable, proven solution with a vibrant ecosystem, having been built up over years and years, designed for the exact purpose of translation, supporting virtually everything you will eventually figure out that you need (plurals, categories, asynchronous workflow, you name it).
  2. Is a poor man's solution which scales up to a few dozen strings to translate and becomes a nightmare to maintain after that. It has no tools to support the workflow, you'll have to reinvent every wheel you'll encounter eventually.
  3. Is 2. with the added disadvantage of not easily being able to version control your translations.

Use an established solution, the problem is not as trivial as it may seem initially. gettext is good, though you'll really need to get into the workflow, which may be a bit of an uphill battle in the beginning.

其他提示

I think the best way is to have everything stored in files on your filesystem. This way, you can not only easily cache it, but it will also work when your database is down. It's also a lot easier to have changes in your VCS such as git or svn. There are several GUI programs available for several different file types to manage this.

Personally, I work with Symfony2 and they have a very easy solution:
http://symfony.com/doc/current/book/translation.html#configuration

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top