At 02:00 2002-04-29 +0800, Autrijus Tang wrote:
Now, the question is: Do you think this is a good enough format for
large catalogs? Our translator (well, me included) doesn't like to
deal with '' and => all the time, and the comment lines really helped
us getting to know the context.
I like your ideas. Try it and see!
I intended the Locale::Maketext format to be a sort of powerful first hack,
but not necessarily something that's right for everyone.
For example, its use of [ and ] as metacharacters is a bit of a problem for
Shift-JIS encoding, which generates [ and ] bytes in strings. So I just
wrote this simple routine to massage things:
sub sworp {
# Treat [ and ] as literal; use { and } as the metacharacters.
# Problem: no real way to get a literal { and }
my @in = @_;
foreach my $x (@in) {
$x =~ s/\[/~[/g;
$x =~ s/\]/~]/g;
$x =~ tr<{}><[]>;
}
@in;
}
%Lexicon = (sworp(
# These are links as well as button text:
'Play All' => '?v???C',
'Shuffle All' => '?V???b?t??', # Stream all in random order
'Stream All' => '?X?g???[?~???O',
# This one in just button text
'Play Selected' => '?`?F?b?N?µ?½?à?Ì?ð?v???C',
"In this demo, streaming is limited to approximately
{quant,_1,second,seconds}."
=> "?±?Ì?f???Å?Í?A?X?g???[?~???O?Í {quant,_1,?b,?b} ?É?À?è?³?ê?Ä?¢?Ü?·?B",
[...]
));
Anyhoo, about the only time I've needed to break out of the format of
one-or-two lines => one-or-two lines is in usage messages. In
File/Findgrep/I18N/fr.pm :
'_USAGE_MESSAGE' =>
# an example of a phrase whose key isn't meant to
# ever double as a lexicon value.
\q{Instructions:
findgrep [options] modèle-ligne [modèle-fichier [noms-de-répertoires...]]
Options:
-R
récurser
[...lots more lines...]
},
Note also that besides being multi-lined, it's \-escaped, which means that
it's taken as a literal, not as containing bracket notation. Whether you'd
want to support such things in whatever catalog format you allow for, is an
open question. It's useful only occasionally, but on those occasions is
reasonably convenient.
On the other hand, beware the prospect of creating another notation with
the same expressive power as Perl, but with needlessly different
syntax! It's the blessing/curse of little languages!
(BTW, "sworp" is dialectal US English for "swap".)
--
Sean M. Burke http://www.spinn.net/~sburke/