[xsl] Need help with using lookup table and string translation

Subject: [xsl] Need help with using lookup table and string translation
From: Dmitri Snytkine <d.snytkine@xxxxxxxxx>
Date: Mon, 11 May 2009 09:18:58 -0400
Hello! I just started working with xslt a couple of days ago.
It's still very new to me, even though I have over 5 years experience
with php and javascript, which at least makes it relative easy to
learn xslt, but I still can use good advice.

This is what I want to acheive:

I am developing a milti-lingual site, and want the transformations
dont by the browser. For that I am including an xml of translations in
a form of a lookup table inside the xsl template file, like this:
 <trans:tr page_id="global">
        <tr_string str="recent_albums">
                Recent Albums
                nOWYE ALXBOMY

                <tr_string str="welcome">
                Welcome to our site
                dOBRO POVALOWATX

        <tr_string str="recent_videos">
                Recent Videos

        <tr_string str="recent_images">
                Recent Images
                nOWYE FOTKI

Then inside the xml file I may have strings like this:

    <gv d="en" c="ru" lm="dynamic" sd="member"/>
        My title

            <div class="recent">
            <img title="ocean">/img1.jpg</img>
            <img title="people">/img2.jpg</img>
            <img title="my dog">/img3.gif</img>



Now how do I make it so that every instance if <trs> tag is replaced
by value of:
if tag <tr_string> with value of "str" = <trs> does not exist, then
return value of <trs> itself
find element <tr_string> with value of 'str' = value of <trs>
and them: if it has child tag named  <ru>, return its value, otherwise
return the value of <en>

In other words: if translaion lookup table has this string, then get
the value or <ru> if it exists and not empty, otherwise fallback to
value of <en>

If translation lookup table does not even have this string, then
return untranslated value.

Anyway, maybe someone has already done something similar for a
multilingual site and maybe there is a better way to store the lookup

I appreciate if anyone can help me with this.

Thank you.

Current Thread