[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Sorting lists by language (was [Fwd: New translation: India])



On Thu, Jul 29, 1999 at 05:24:37PM +0200, peter karlsson wrote:
> > Order matters. The changes I committed worked fine, once I fixed
> > the slice in consultants.wml that wasn't closed.
> 
> Speaking of the consultants page, and also of the other pages that have
> countries listed in some order; the country names are order alphabetically
> by their English names, which doesn't really work very well in all other
> languages (for example "Austria" is in Swedish "Österrike", where "Ö" is the
> last letter of the Swedish alphabet).
> 
> Does anyone have a better idea to sort these, other than manually?
> 
Perl is the answer.

For the links to pages in other languages at the bottom of every page
I used a hash and sorted it. Since I didn't set the locale it
probably isn't perfect, but should be a lot better than nothing.
If internal URLs are named using the same string as the keys in the
hash this shouldn't be difficult.

Note that I only used a hash for the language names. Country names
are simply stored using tags and slices. A similar hash would need
to be created for country names. Luckily we already have the needed
translations.

Here's a quick stab for the list of countries at the top of the
consultants page. Note that the actual order of the consultants in
the page will be the same for every lang. Totally untested.

<perl>
@consult_country = ("Argentina", "Australia", "Austria", "Belgium", ... ,
      "UK", US");
# create a hash containing all the translations of the countries in @consult_country
foreach (@consult_country) {
   $translated_countries{$trans{$CUR_ISO_LANG}{$_}} = $_;
}
print "<UL>\n";
# if someone more familiar with localization would like to implement this
# using using locales, be my guest.
foreach (sort keys %translated_countries) {
	$cur_country = $translated_countries{$_};
	print "<LI><A HREF=\"#$cur_country\">$cur_country</A> </LI>\n";
}
print "</UL>\n";
</perl>

If you feel this is important, feel free to implement it.
It would be even better if you go one step further so that a page
can simply call a function giving the list of countries and a
string and the sorted text is automatically printed out.

Jay Treacy


Reply to: