Re: How to use Unicode::Collate in multilinguage apps?

[email protected] (Rich)
Newsgroups perl.unicode
Message-ID <[email protected]>
Sadahiro Tomoyuki wrote:

<snip>

> I write Unicode::Collate::Locale (tentatively) for linguistic tailoring
> of UCA. To use it, Unicode::Collate should search allkeys.txt
> from any directories in @iNC (at present it searchs table files
> only under the directory where it locates.)
> So Unicode::Collate::Locale should require Unicode::Collate 0.40 or later,
> which is not released yet, but a prerelease is available as shown below.
> 
> [tarball]
>
http://homepage1.nifty.com/nomenclator/perl/Unicode-Collate-Locale-0.01.tar.gz
> [doc]
> http://homepage1.nifty.com/nomenclator/perl/Unicode-Collate-Locale.html
>    Sorry, now tailoring of only few languages are implemented.
>    It may be enhanced sooner or later...
> 
> [prerelease] This will be released *after* Perl 5.8.4 (or its RC) will be
> [out.
> http://homepage1.nifty.com/nomenclator/perl/Unicode-Collate-0.40.tar.gz

Thank you and Jarkko for your replies.

I now realise that some per-language tailoring would be needed for sensible
results. Unicode::Collate::Locale seems like the kind of think I was
looking for, and any tailoring is better than none :)

Using the multi-lingual server scenario I was initially discussing, would
one of the following usages be correct (yes, it's just pseudocode and
exists in a world where no errors ever occur!):

1)

 my %collators;

 for ( $server_loop )
 {
   my $lang_tag = Server->requested_lang_tag;

   my $collator   = $collators{$lang_tag} 
                ||= Unicode::Collate::Locale->new(locale => $lang_tag);

   ...
 }


2)

  my $prev_lang;
  my $collator;

  for ( $server_loop )
  {
    my $lang_tag = Server->requested_lang_tag;

    unless ( $lang_tag eq $prev_lang )
    {
      $prev_lang = $lang;
      $collator  = Unicode::Collator::Locale->new(locale => $lang_tag);
    }

    ...
  }


Which would be the preferred way of handling this (or are both wrong)?

Again, thanks for your replies.
-- 
Rich
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.