5

I have a website written in PHP with 15-20 pages and they have lots of text. I have to translate it to 3 different languages. First, I tried using strings ($text_hello = "你好";) but that option gets very tedious and hard to manage with 50+ strings. I also discovered gettext option and it's good. But I was interested particularly in a (MySQL) database backed option, where all translation would be fetched from database. Also, I may be wrong, but with gettext, you've to have that extra index.php?lang=en_US (?) I want it to change just like it's on Twitter or Facebook, where URL doesn't change. Can you suggest me how to do this or guide me to tutorial/article/previous questions on this topic? Thanks!

Also, I saw people recommending Zend_Translate, but does that require me to re-write my website in Zend framework?

Before asking, I did search for it, but the results I got weren't what I was looking for.

tmrhmdv
  • 172
  • 2
  • 13

1 Answers1

4

Also, I may be wrong, but with gettext, you've to have that extra index.php?lang=en_US

Yes you are wrong , the lang parameter can be hidden if you like (using session and/or cookie for example). It also can be a part of your SEO strategy (url like /en/mypage or /fr/mypage)

Multilang with databases is an option , but i'm not a big fan of adding extra queries if it just to get some translation for the interface.
Some links which could be usefull : Schema for a multilanguage database
What are best practices for multi-language database design?

Also, I saw people recommending Zend_Translate, but does that require me to re-write my website in Zend framework?

You can just extract Zend_Translate (and it's dependency) and use it as a library

Community
  • 1
  • 1
grunk
  • 14,718
  • 15
  • 67
  • 108