From: "W.H. Dekker" <wybo@servaly.hobby.nl>
Subject: new version of tran for context keyword translation
Date: Fri, 31 Jul 1998 17:11:48 +0200 [thread overview]
Message-ID: <199807311511.RAA00208@servaly.hobby.nl> (raw)
Here is a new version. Please mind: language keys have changed:
e -> English
d -> Dutch
g -> German
#!/usr/bin/perl -w
=head1 NAME
tran - show translations for context commands and keywords
=head1 SYNOPSIS
tran en|ne|ed|de|nd|dn command-name_or_keyword...
tran en|ne|ed|de|nd|dn <file_containing_commnds_or_keywords
=head1 DESCRIPTION
B<tran>, given one or more context command names or keywords, or a
file (on standard input) containing those, B<tran> prints each of them
with its translation on standard output. The source language and the
target language are given with the first parameter,
which must be a key consisting of two letters, one for the source
language and for the target language. Currently the only allowed
letters are d, e and g for Dutch, English and German.
=head1 EXAMPLES
From Dutch to English:
$ tran de taal starttekst hoogte
taal -> language
starttekst -> starttext
hoogte -> height
From English to German:
$ tran eg language starttext height
language -> sprache
starttext -> starttext
height -> hoehe
Given a file test.tex, containing:
\starttekst
\omlijnd[hoogte=ruim]{Hello world!}
\stoptekst
you can show the translation for every Dutch context command or
keyword in English with:
$ tran de <test.tex
hoogte -> height
omlijnd -> framed
ruim -> broad
starttekst -> starttext
stoptekst -> stoptext
=head1 ENVIRONMENT
All terms and their translations are taken from the files
F<mult-con.tex> and F<mult-con.tex>. These are supposed to reside in
the directory $ENV{TETEXDIR}/temf/tex/context/base.
=head1 AUTHOR
Wybo H. Dekker (wybo@servaly.hobby.nl)
=cut
use vars qw($d $e $g);
%lang=(d => 'dutch',
e => 'english',
g => 'german',
);
($myname=$0) =~ s|.*/||;
$xy=shift or die "Usage: $myname xy\nwith x=d|e|g and y=d|e|g and x ne y\n";
$xy=~/^de|dg|ed|gd|ge|eg$/ or die "translation must be from d|e|g to d|e|g\n";
($x,$y)=split(//,$xy);
$ENV{TETEXDIR} or $ENV{TETEXDIR}='.';
$dir="$ENV{TETEXDIR}/texmf/tex/context/base"; # where mult-co[nm].tex should be
$name='([a-zA-Z]+)'; # search pattern for translatable terms
openin("mult-com");
while (<IN>) {
next unless /^\s*$name:\s+$name\s+$name/;
($d,$e)=($2,$3);
($g=<IN>) =~ tr /a-zA-Z//cd ;
$xy{$$x}=$$y;
}
openin("mult-con");
while (<IN>) {
next unless /^\s*$name:\s+$name\s+$name\s+$name/;
($d,$e,$g)=($2,$3,$4);
$xy{$$x}=$$y;
}
close IN;
if (@ARGV) {
for (@ARGV) {
if ($xy{$_}) { $translation=$xy{$_}; write }
else { print "$_ is not a valid command or keyword in $lang{$x}\n" }
}
} else {
while(<>) { for (split(/\W/)) { $w{$_}++ } }
for (sort keys %w) {
next unless ($translation=$xy{$_} ? $xy{$_} : "");
write
}
}
format =
@>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -> @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$_,$translation
.
sub openin {
open(IN,"$dir/$_[0].tex") and return;
die "Could not open $dir/$_[0].tex\n".
"Please check your environment variable TETEXDIR\n".
"it should point to the directory where texmf/ resides\n";
}
--
Kind regards,
Wybo
===================Servalys Analytical Chemistry Services=================
Wybo H. Dekker | Deilsedijk 60 | tel (31)345-652164
wybo@servaly.hobby.nl | 4158 CH Deil, The Netherlands | fax (31)345-652383
reply other threads:[~1998-07-31 15:11 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199807311511.RAA00208@servaly.hobby.nl \
--to=wybo@servaly.hobby.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).