From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/110 Path: main.gmane.org!not-for-mail From: "W.H. Dekker" Newsgroups: gmane.comp.tex.context Subject: new version of tran for context keyword translation Date: Fri, 31 Jul 1998 17:11:48 +0200 Sender: owner-ntg-context@let.uu.nl Message-ID: <199807311511.RAA00208@servaly.hobby.nl> NNTP-Posting-Host: coloc-standby.netfonds.no X-Trace: main.gmane.org 1035390986 21373 80.91.224.250 (23 Oct 2002 16:36:26 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 23 Oct 2002 16:36:26 +0000 (UTC) Original-To: ntg-context@ntg.nl Xref: main.gmane.org gmane.comp.tex.context:110 X-Report-Spam: http://spam.gmane.org/gmane.comp.tex.context:110 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 , given one or more context command names or keywords, or a file (on standard input) containing those, B 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 height omlijnd -> framed ruim -> broad starttekst -> starttext stoptekst -> stoptext =head1 ENVIRONMENT All terms and their translations are taken from the files F and F. 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 () { next unless /^\s*$name:\s+$name\s+$name/; ($d,$e)=($2,$3); ($g=) =~ tr /a-zA-Z//cd ; $xy{$$x}=$$y; } openin("mult-con"); while () { 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