I have the usual Apache/Perl/CGI::Application setup -- one instance script in index.cgi, a bunch of packages, setup, and a bunch of HTML::Templates. So, run mode "welcome" uses welcome.tmpl, rm edit uses edit.tmpl and so on.

Right. Now we want to set up all the templates in different languages. So when folks from Germany visit the website, they get welcome.de.tmpl, folks from Latin America get welcome.es.tmpl, and us folks get welcome.en.tmpl.

Easy to do with Apache and its content negotiation. The browser (hopefully) sends a header, and Apache serves the correct language pages. Of course, if some goes snafu, the browser doesn't send the correct header, or the user simply wants to see another language, I can have a pull-down menu or some such widget to let the user switch languages.

But, everything is being intercepted and acted upon by our favorite language, so how do I do the content negotiation with Perl/CGI::Application?

Update: I guess I could make lang specific index.cgi... so, index.en.cgi, index.de.cgi, and so on, which then would call the appropriate templates. But that would be so lame... any changes in my program and I would have to make the change as many times as my lang versions. Oh what to do, what to do?

--

when small people start casting long shadows, it is time to go to bed

In reply to content negotiation with Apache/cgi by punkish

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.