Golly, I just finished making one of my programs multi-lingual, so I read this post at JUST the right time. I don't know if this is the BEST solution:) But it seems to be working for me.
First, I must admit that I do not speak every language on the planet. Knowing this, I wanted to put the translation engine into a script that would allow other, non-programmers, to update the language sections that they have expertise in and keep me from having to re-write the code every time.
One solution I saw, was to use translation files that the script would call. Each file would have a list of variable definitions $language{'submit_button_text}="Submit";
$language{'web_title_text'}="programmercentral.org";
etc...
The problem with this is that it's a pain for your translator to view the 'original' text and produce clean, translated text. It's a very labor-intensive task and means that you (the maintainer) have to spend a lot of time looking over the translator's shoulder to make sure that they don't break syntax.
So, here was my solution (finally): I put the text for the web site into a MySQL database. I tried to make it as atomic as possible and rely heavily on CSS to handle my formatting. In this way, the translation information itself is free of HTML markup and requires NO expertise for the translator.
Next, I set up a simple web interface (behind .htaccess) that lets my officially sanctioned translator to open a web page and display any current language information, as well as blanks for his new language side by side. He/she just walks down the form and translates whatever is in the left box to the new language in the right box. This solves the
expertise problem and makes it easy for any off the shelf translation professional to update your site.
Now, within the script itself, I simply check for which language I should be looking at, dump the contents of the language to a hashref, then look in the hashref whenever it is time to display text to the screen. From this point forward, all I need to do to update the whole site is add a column to my language table and find a translator that speaks one of the current languages and the target language. After that, update a couple of tags making the new language 'live' on the site and PRESTO, new language. This has worked VERY well and my customer has been pleased with the solution too.
My two Euro-cents,
-oakbox |