RE: Q&A -- sorting

Richard,

Accepted.  Updated version follows:


=-=-=-=-=-=-=-=-=-=-=-

Question:

As part of a form, I have a list of terms in a drop-down box.  Why are they not correctly sorted when I translate the items in the list?

Answer:

Although many programming languages have devices like drop-down boxes that have the capability of sorting a list of items before displaying them as part of their functionality, the HTML <select> function has no such capabilities.  It lists the <options> in the order received.  Thus one must pre-sort their translated options before presenting them to the client.  This is either done manually or by using some developer-designed process (like using an XSLT transform).

For example, lets say we have a pull-down list for types of pets.  In 
the list, we have the following in alphabetical order:

<form .....>
    <select size="1" name="pet">
       <option value='cat'> cat </option>
       <option value='dog'> dog </option>
       <option value='mouse'> mouse </option>
    </select>
...
...
</form>

When this is translated to Dutch, the list becomes

<form .....>
    <select size="1" name="pet">
       <option value='cat'> kat </option>
       <option value='dog'> hond </option>
       <option value='mouse'> muis </option>
    </select>
...
...
</form>

But for it to be in correct Dutch alphabetical order, we will need to 
re-arrange the list to:

<form .....>
    <select size="1" name="pet">
       <option value='dog'> hond</option>
       <option value='cat'> kat </option>
       <option value='mouse'> muis </option>
    </select>
...
...
</form>

This must be done for each language to be displayed.

Note that the value parameters are not translated in the examples above.  This separation of material to be displayed to the user and data to be processed at the back-end, allows the developer to keep the back-end processing the same.  Meaning they do not have to change what they expect to receive from the user every time support for a new language is added. 




-----Original Message-----
From: Richard Ishida [mailto:ishida@w3.org] 
Sent: Wednesday, May 07, 2003 10:39 PM
To: Russ Rolfe; public-i18n-geo@w3.org

Hi Russ,

Thanks for getting this back out so quickly.  I'd like to suggest one small tweak:

> developer-designed process (like using XML and XSLT).

You can run XSLT on the HTML itself, you don't need the data to be in XML, so to avoid making things sound to difficult we could just say

"developer-designed process (like using an XSLT transform)."

Hth,
RI

============
Richard Ishida
W3C

tel: +44 1753 480 292
http://www.w3.org/International/
http://www.w3.org/People/Ishida/



> -----Original Message-----
> From: Russ Rolfe [mailto:rrolfe@windows.microsoft.com]
> Sent: 07 May 2003 21:04
> To: ishida@w3.org; public-i18n-geo@w3.org
> Subject: Q&A -- sorting
> 
> 
> Dear all,
> 
> Thank-you for the input.  Please let me know if you have any 
> suggestions, deletions or additions.
> 
> Regards, Russ
> 
> =-=-=-=-=-=-=-=-=-=-=-
> 
> Question:
> 
> As part of a form, I have a list of terms in a drop-down box. 
>  Why are they not correctly sorted when I translate the items in the 
> list?
> 
> Answer:
> 
> Although many programming languages have devices like drop-down boxes 
> that have the capability of sorting a list of items before displaying 
> them as part of their functionality, the HTML <select> function has no 
> such capabilities.  It lists the <options> in the order received.  
> Thus one must pre-sort their translated options before presenting them 
> to the client.  This is either done manually or by using some 
> developer-designed process (like using XML and XSLT).
> 
> For example, lets say we have a pull-down list for types of pets.  In 
> the list, we have the following in alphabetical order:
> 
> <form .....>
>     <select size="1" name="pet">
>        <option value='cat'> cat </option>
>        <option value='dog'> dog </option>
>        <option value='mouse'> mouse </option>
>     </select>
> ...
> ...
> </form>
> 
> When this is translated to Dutch, the list becomes
> 
> <form .....>
>     <select size="1" name="pet">
>        <option value='cat'> kat </option>
>        <option value='dog'> hond </option>
>        <option value='mouse'> muis </option>
>     </select>
> ...
> ...
> </form>
> 
> But for it to be in correct Dutch alphabetical order we will need to 
> re-arrange the list to:
> 
> <form .....>
>     <select size="1" name="pet">
>        <option value='dog'> hond</option>
>        <option value='cat'> kat </option>
>        <option value='mouse'> muis </option>
>     </select>
> ...
> ...
> </form>
> 
> This must be done for each language to be displayed.
> 
> Note that the value parameters are not translated in the examples 
> above.  This separation of material to be displayed to the user and 
> data to be processed at the back-end, allows the developer to keep the 
> back-end processing the same.
> Meaning they do not have to change what they expect to receive from 
> the user every time support for a new language is added.
> 
> 
> 

Received on Thursday, 8 May 2003 12:06:03 UTC