Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
204 views
in Technique[技术] by (71.8m points)

php - How would you transform a pre-existing web app into a multilingual one?

I am going to work on a project where a fairly large web app needs to tweaked to handle several languages. The thing runs with a hand crafted PHP code but it's pretty clean.

I was wondering what would be the best way to do that?

  1. Making something on my own, trying to fit the actual architecture.

  2. Rewriting a good part of it using a framework (e.g., Symfony) that will manage i18n for me?

For option 1, where should I store the i18n data? *.po, xliff, pure DB?

I thought about an alternative: using Symfony only for the translation, but setting the controller to load the website as it already is. Quick, but dirty. On the other hand, it allows us to make the next modification, moving slowly to full Symfony: this web site is really a good candidate for that.

But maybe there are some standalone translation engines that would do the job better than an entire web framework. It's a bit like using a bazooka to kill a fly...

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Work with languages files.

  1. Replace each text string by a variable
  2. Create one language file per language and in it define each variable with their corresponding text. (french.inc, dutch.inc ...)
  3. Include the right file in each page.

That's for small sites.

If getting bigger, replace the files by a DB. :)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...