Multilingual Web App
Has anyone here ever developed a website that supported multiple languages? I'm wondering how to best implement that kind of thing from a programming standpoint. Any tips or good links?
Has anyone here ever developed a website that supported multiple languages? I'm wondering how to best implement that kind of thing from a programming standpoint. Any tips or good links?
pr0gr4mm3r posted this at 13:18 — 24th March 2008.
He has: 1,502 posts
Joined: Sep 2006
The best way would probably to see how other scripts like Wordpress or Drupal do it.
It looks like PHP will support i18n in version 6. (link)
Gettext seems to be the most popular way to do it. I read through the tutorial, and I think that's what Wordpress uses.
JeevesBond posted this at 20:25 — 25th March 2008.
He has: 3,956 posts
Joined: Jun 2002
This is done in Drupal by running all strings through the t() function, which implements the locale.module. The part where translations are loaded is locale_system_update(). Drupal loads them into the db via a batch operation.
Think the convention, in Gettext as pr0gr4mm3r pointed out, is to run all strings shown in your interface through a translate function (such as t() or _() ). Then store the translations in a po or translations directory (however that best fits in with the system you're building), when t() is called it looks the string up in the file(s) contained in translations directory. If there is a substitute string, and that string is for the language the user has selected then return it. Otherwise t() should just return the string originally given to it.
A bit confusing, but hope this helps.
a Padded Cell our articles site!
teammatt3 posted this at 18:03 — 26th March 2008.
He has: 2,102 posts
Joined: Sep 2003
I think I actually understand what's going on with t(). Thanks Jeeves and Drupal writers .
I like t() because it is something that can be ported to different languages pretty easily. I didn't want to use something that was too PHP specific because I might have to do something like this in another language.
Thanks for the help guys.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.