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


In reply to Re: Multilingual Perl applications by oakbox
in thread Multilingual Perl applications by rinceWind

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.