#!/usr/bin/perl -w # vim: set sw=4 ts=4 si et: # Author: Guido Socher, guido@bearix.oche.de # This software ist distributed under the conditions of the # GNU public license. use strict; use vars qw($opt_h $opt_l $opt_p $opt_r $opt_t $opt_s); use Getopt::Std; # my $l=0; my $ver="version 2.8.a"; my $verdate="Apr 24 2000"; my $month; my $monthdir; my $bg; my ($i,$state); my $nm; #nickname my @line; my %templates; my $today; my $usr; my $respemail; my $respname; my %nick2real; my %nick2e; my %lang2dir=('en'=>'English','de'=>'Deutsch','fr'=>'Francais', 'nl'=>'Nederlands','es'=>'Castellano'); # LinuxFocus got messy over the initiative to change the article location # from MonthYear to articles directory. # This tells us per issue where things are. The syntax is # 'issue_name'=>'directory' # issue_name is the term that comes after the "month:" in the defintion file. # By default the article is searched in Language/Month # Add therefore only the locations which are not in line with this. my %whereiswhat=( 'en'=>{'July1998'=>'articles','September1998'=>'articles','October1998'=>'articles','November1998'=>'articles','December1998'=>'articles','January1999'=>'articles','Next'=>'../WorkSpace/Nextissue','July1999'=>'July1999'}, 'de'=>{"November1997"=>'November1997'}, 'fr'=>{'July1998'=>'articles','September1998'=>'articles','October1998'=>'articles','November1998'=>'articles','December1998'=>'articles','January1999'=>'articles','Next'=>'../WorkSpace/Nextissue','July1999'=>'July1999'}, 'nl'=>{'July1998'=>'articles','September1998'=>'articles','October1998'=>'articles','November1998'=>'articles','December1998'=>'articles','January1999'=>'articles','Next'=>'../WorkSpace/Nextissue','July1999'=>'July1999'}, 'es'=>{'July1998'=>'articles','September1998'=>'articles','October1998'=>'articles','November1998'=>'articles','December1998'=>'articles','January1999'=>'articles','Next'=>'../WorkSpace/Nextissue','July1999'=>'July1999'}, ); # # &getopts("l:hprts")||exit 1; &help if ($opt_h); &help if (scalar(@ARGV) < 1); die "ERROR: can not read file $ARGV[0]\n" unless (-r "$ARGV[0]"); $usr=(getpwuid($<))[6]; # for some reason many Linux users do not have the full name in /etc/passwd: $usr=(getpwuid($<))[0] unless ($usr=~/\w/); $today=&today; if ($opt_t){ &textpage($ARGV[0]); exit 0; #that's it } &readtemplates(); &printtemplate("__dochead"); unless($opt_l){ $opt_l='en'; &printtemplate("__info_en"); $respemail='guido.socher@linuxfocus.org'; $respname='Guido Socher'; }else{ if ($opt_l eq "de"){ $respname='Guido Socher'; $respemail='guido.socher@linuxfocus.org'; &printtemplate("__info_de"); &printtemplate("__info_en"); } elsif ($opt_l eq "nl"){ $respname='het Nederlandse LinuxFocus team'; $respemail='dutch@linuxocus.org'; &printtemplate("__info_nl"); &printtemplate("__info_en"); } elsif ($opt_l eq "es"){ $respname='Javier Palacios Bermejo'; $respemail='javier.pb@linxfocus.org'; &printtemplate("__info_es"); &printtemplate("__info_en"); } elsif ($opt_l eq "fr"){ $respname='Eric Santonacci'; $respemail='eric.santonacci@linuxfocus.org'; &printtemplate("__info_fr"); &printtemplate("__info_en"); }else{ $opt_l='en'; print STDERR "ERROR: unknown language $opt_l, using english\n"; &printtemplate("__info_en"); $respemail='guido.socher@linuxfocus.org'; $respname='Guido Socher'; } } htmlpage($ARGV[0]); # #------------------ sub textpage($){ my $file=shift; print " Num Title Vertaald door"; if ($opt_p) {print " Gecontroleerd\n";}else{print "\n";} print "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n"; open(FF,"$file")||die "ERROR: can not read $file\n"; while(){ $l++; next if (/^#/); # ignore comment next unless (/\w/); # ignore empty line chomp; s/\s+/ /g; # manny space to 1 space s/^ //g; # leading space # this is a simple un-webify (take first letter after &-sign: s/"/"/g; s/&(\w)\w+;/$1/g; # if (/^\s*nickname:\s*(\w+)/){ # we found a nickname definition $nm=$1; @line=split(/\+\+/); unless ($line[2] && $line[1] && $line[2]=~/\w/ && $line[1] =~/\w/){ print STDERR "ERROR: line $l nickname must have e-mail and real name\n"; next; } unless ($line[1] =~ /\@/){ print STDERR "ERROR: line $l nickname has invalid e-mail field\n"; next; } $line[1]=~s/ +//g; $line[2]=~s/^ //g; $line[2]=~s/ $//g; $nick2real{$nm}=$line[2]; $nick2e{$nm}=$line[1]; next; } @line=split(/\+\+/); if (/^month:/){ $line[0]=~ s/^month://; $month=$line[1]; print "\n=== $month ===\n"; next; } if (scalar(@line) < 3){ print STDERR "ERROR: line $l does not look correct, ignored\n"; next; } unless ($line[2] && $line[2]=~/\w\w/){ print STDERR "ERROR: line $l does not have an article title\n"; next; } for $i (0..6){ # take care of empty fields: if (defined $line[$i] && $line[$i] =~ /\w/){ $line[$i] =~ s/\s//g if ($i == 0 || $i == 1); $line[$i] =~ s/^ //; # we have max one space $line[$i] =~ s/ $//; }else{ $line[$i]=" "; } } if ($line[1]=~/\w/){ #article available if ($line[1] eq "u"){ print "u"; }else{ print ">"; } }else{ print " "; } $line[0]="--" unless($line[0] =~/\d/); #art num: print &fill($line[0],4); #title: print &fill($line[2],44); print " "; #translator: print &fill(&gen_fullname($line[3],$line[4]),20); print " "; #proofreader (do not fill!): print substr(&gen_fullname($line[5],$line[6]),0,20) if ($opt_p); print "\n"; } print "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n"; print "A \">\" at the start of a line means html file available.\n"; print "A \"u\" at the start of a line means file available but not complete.\n"; print "produced with lfmainindex $ver\n"; print " date: $today\n"; print "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n"; } #-------------- sub htmlpage($){ my $file=shift; my $totcount=0; my $percent; my $doc_size; my $afile; my $asfile; my $readycount=0; open(FF,"$file")||die "ERROR: can not read $file\n"; while(){ $l++; next if (/^#/); # ignore comment next unless (/\w/); # ignore empty line chomp; s/\s+/ /g; # manny space to 1 space s/^ //g; # leading space if (/^\s*nickname:\s*(\w+)/){ # we found a nickname definition $nm=$1; @line=split(/\+\+/); unless ($line[2] && $line[1] && $line[2]=~/\w/ && $line[1] =~/\w/){ print STDERR "ERROR: line $l nickname must have e-mail and real name\n"; next; } unless ($line[1] =~ /\@/){ print STDERR "ERROR: line $l nickname has invalid e-mail field\n"; next; } $line[1]=~s/ +//g; $line[2]=~s/^ //g; $line[2]=~s/ $//g; $nick2real{$nm}=$line[2]; $nick2e{$nm}=$line[1]; next; } @line=split(/\+\+/); if (/^month:/){ &printtemplate("__endtab") if ($month); # don't print first time $line[0]=~ s/^month://; $monthdir=$line[0]; $monthdir=~s/ +//g; $month=$line[1]; &printtemplate("__starttab1"); print "$month\n"; &printtemplate("__starttab2"); &printtemplate("__starttab3") if ($opt_p); print "\n\n"; next; } if (scalar(@line) < 3){ print STDERR "ERROR: line $l does not look correct, ignored\n"; next; } unless ($line[2] && $line[2]=~/\w\w/){ print STDERR "ERROR: line $l have an article title\n"; next; } unless(/^\d/ || $line[1]=~ /\w\w\w/){ print STDERR "ERROR: line $l does not start with a digit and at the same time no full path to non-english page is given\n"; next; } for $i (0..6){ # take care of empty fields: if (defined $line[$i] && $line[$i] =~ /\w/){ $line[$i] =~ s/\s//g if ($i == 0 || $i == 1); $line[$i] =~ s/^ //; # we have max one space $line[$i] =~ s/ $//; }else{ $line[$i] = ""; } } $totcount++; print "\n "; $bg=" BGCOLOR=\"#C2C2C2\""; if ($line[1] eq "u" && $line[0] =~/^\d/){ $bg=" BGCOLOR=\"#AAAAFF\""; # blue }elsif ($line[1]=~/\w/ && $line[0] =~/^\d/){ $readycount++; #$bg=" BGCOLOR=\"#FFFFFF\""; # the background is white $bg=""; }elsif ($line[3]=~/\w/){ # a nickname or e-mail $bg=" BGCOLOR=\"#AAAAFF\""; # blue } # now print the first column: # It may be that there is not an english version. # E.g the original article is spanish. In this case we do not # have a digit in $line[0] and the full path in $line[1] unless ($line[0] =~ /\d/){ print "--"; }else{ print ""; if ($opt_r){ #abs path print "$line[0]"; } # now print the second print ""; if ($line[1] =~/^[XxUu]$/){ if ("$line[0]" eq "0"){ print ""; }else{ if ($whereiswhat{$opt_l}{$monthdir}){ $afile="$whereiswhat{$opt_l}{$monthdir}/article$line[0].html"; $asfile="$whereiswhat{$opt_l}{$monthdir}/article$line[0].shtml"; }else{ # default if whereiswhat is not defined: $afile="$monthdir/article$line[0].html"; $asfile="$monthdir/article$line[0].shtml"; } if ( -f $lang2dir{$opt_l}."/$asfile"){ print ""; }elsif (-f $lang2dir{$opt_l}."/$afile"){ print ""; }else{ print STDERR "Warning: can neither find $lang2dir{$opt_l}/$asfile nor $lang2dir{$opt_l}/$afile. You don\'t seem to have the LF articles on your harddisk or you are in the wrong directory. I will use now .shtml\n"; print ""; $doc_size=""; } } print "$line[2]"; } elsif ($line[1] =~/\w/){ # article not yet translated and full path given: print "$line[2]"; }else{ if ("$line[0]" eq "0"){ if ($whereiswhat{'en'}{$monthdir}){ $afile="$lang2dir{en}/$whereiswhat{en}{$monthdir}/index.html"; $asfile="$lang2dir{en}/$whereiswhat{en}{$monthdir}/index.html"; }else{ $afile="$lang2dir{en}/$monthdir/index.html"; $asfile="$lang2dir{en}/$monthdir/index.html"; } }else{ # article not translated yet. First we must find the # corresponding English article to calculate the size. if ($whereiswhat{'en'}{$monthdir}){ $afile="$lang2dir{en}/$whereiswhat{en}{$monthdir}/article$line[0].html"; $asfile="$lang2dir{en}/$whereiswhat{en}{$monthdir}/article$line[0].shtml"; }else{ # use default: $afile="$lang2dir{en}/$monthdir/article$line[0].html"; $asfile="$lang2dir{en}/$monthdir/article$line[0].shtml"; } } # default: $doc_size=0; if ($opt_s){ if ( -f $asfile){ $doc_size=`wc -w $asfile`; # use only the word count (not the file name) if ($doc_size=~/(\d+)/){ $doc_size=$1; } }elsif (-f $afile){ $doc_size=`wc -w $afile`; # use only the word count (not the file name) if ($doc_size=~/(\d+)/){ $doc_size=$1; } }else{ print STDERR "Warning: can neither find $afile not $asfile. Can\'t add article size\n"; } } if ($doc_size){ print "$line[2] ($doc_size words)"; }else{ print "$line[2]"; } } print ""; # now handle the translator reader gen_emailfield($line[3],$line[4]); # now handle the proof reader gen_emailfield($line[5],$line[6]) if ($opt_p); print "\n"; } &printtemplate("__endtab") if ($month); # don't print if no data print "
\n

Deze pagina is gemaakt met "; print ""; print "lfmainindex, $ver, op: $today\n"; print "

Deze pagina wordt onderhouden door: "; print "$respname

\n"; $totcount =1 unless ($totcount); #handle div by zero $percent= 100 * $readycount / $totcount; print "

$readycount artikelen van de $totcount = "; printf ("%3d %% vertaald

\n",$percent); &printtemplate("__enddoc"); } #-------------- sub fill($,$){ #fill string with spaces or cut string to desired size my $str=shift; my $len=shift; $str.=" "; substr($str,0,$len); } #-------------- sub gen_fullname($,$){ # generate an full name string # The variables may not be undef!! my $emailcol=shift; my $realcol=shift; my $ret=" "; # if ($emailcol =~ /@/ && $realcol =~/\w/){ # a valid e-mail $ret=$realcol; }elsif ($line[3] && $nick2e{$emailcol}){ $ret=$nick2real{$emailcol}; }elsif ($emailcol){ $ret=" "; }else{ print STDERR "ERROR: line $l, name and e-mail missing, or undef nickname\n"; } $ret; } #-------------- sub gen_emailfield($,$){ # generate an e-mail field or an empty one if the data is not there # The variables may not be undef!! my $emailcol=shift; my $realcol=shift; # # now print the third column: print ""; if ($emailcol =~ /@/ && $realcol =~/\w/){ # a valid e-mail print "$realcol"; }elsif ($emailcol && $nick2e{$emailcol}){ print "$nick2real{$emailcol}"; }elsif ($emailcol =~/\w/){ print STDERR "ERROR: Line $l, name and e-mail missing, or undef nickname \n"; print " "; }else{ print " "; #empty field } print "\n"; } #-------------- sub today{ my @ltime = localtime; #return a date in yyyy-mm-dd format my $today; $today = sprintf("%04d-%02d-%02d",1900 + $ltime[5],$ltime[4] + 1,$ltime[3]); $today; } #-------------- sub printtemplate($){ my $name=shift; if (defined $templates{$name}){ foreach (@{$templates{$name}}){ print; } }else{ print STDERR "ERROR: No such template $name\n"; print "

lfmainindex: template error, no $name

\n"; } } #-------------- sub readtemplates(){ my $templatename="nix"; #read and print any text between "^__ xxx" and the next __ while(){ next if (/^#/); if (/^(__\w+)/){ $templatename=$1; next; } push(@{$templates{$templatename}},$_); } } #------------- sub help{ print "lfmainindex -- generate a LinuxFocus translation index page from index definition file USAGE: lfmainindex [-hprst][-l de|es|fr|nl] index_definition_file OPTIONS: -h this help text -p Print information about the proofreader -r Do not use relative links for the English pages. If this option is given then the links to the English page will be absolute starting with http://www.linuxfocus.org/ -s Print the size behind not yet translated articles. -t Print plain text output -l specify the language. This is to write the correct header and find the files. A few lines and column headings will still be printed in english. EXAMPLE: lfmainindex -l es spanish_index_def.txt > indexpage.html or lfmainindex -l de -p lf_deutsch_def.txt > indexpage.html The latest version can be downloaded from http://www.linuxfocus.org/developer/Guido/ Since version 2.8 you need to run this program while standing infront of the LinuxFocus directory tree (you need a local copy of all the files for your Lanuage). This is needed because the program has no other means to decide if the article is a .html or .shtml file. This program was wtitten by Guido Socher (guido.socher\@linuxfocus.org) $ver, $verdate \n"; exit; } __END__ __info_en

LinuxFocus translators page

This is an index of all LinuxFocus articles. Already translated articles are shown with white background. Articles that are grayed are not translated yet and articles with blue background are reserved for translation but not yet ready.

You can help LinuxFocus! If you see an article that is not yet translated and you would like to translate it then reserve it for you by sending an e-mail to the person mentioned as maintainer at the end of this page.

__info_es

Índice principal de LinuxFocus

Éste es el indice de todos los artículos publicados en LinuxFocus. Los artículos ya traducidos aparecen con el fondo blanco; en gris los que toravía no están traducidos y los de fondo en azul están en fase de traducción.

¡Tú puedes colaborar con LinuxFocus! Puedes traducir cualquiera de los artículos que quedan por traducir con solo ponerte en contacto por e-mail con el responsable de este grupo. La dirección la encontraras al final de esta página.

__info_pt

LinuxFocus - Indice Principal

Este é um índice de todos os artigos da LinuxFocus. Artigos já traduzidos são mostrados com fundo branco. Artigos com fundo cinza ainda não foram traduzidos e artigos com fundo azul estão reservados para tradução e ainda não estão prontos.

Você pode ajudar a LinuxFocus! Se você encontrar um artigo que ainda não está traduzido e você gostaria de traduzí-lo, entáo reserve-o para você enviando um e-mail para a pessoa mencionada como gerenciador no final desta página, e mãos-à-obra.

__info_fr

Index principal de LinuxFocus

Voici un index de tous les articles de LinuxFocus. Les noms des articles déjà traduits sont sur fond blanc. Les articles sur fond gris ne sont pas encore traduits et ceux avec un fond bleu sont en cours de traduction.

Vous pouvez aider LinuxFocus! Si vous voyez un article non encore traduit et que vous aimeriez le traduire, réservez-le en envoyant un émel à la personne concernée. Vous trouverez son adresse en fin de page.

__info_nl

LinuxFocus Overzicht

Dit is een overzicht van alle LinuxFocus artikels. Artikels die al vertaald zijn, hebben een witte achtergrond. Een grijze achtergrond betekent 'nog niet vertaald' en artikels met een blauwe achtergrond zijn reeds gereserveerd voor vertaling, maar nog niet afgewerkt. Artikelen die een *M* voor hun naam hebben staan, zijn nog niet omgezet naar het .meta.html formaat.

U kan LinuxFocus helpen! Als je een artikel ziet dat nog niet vertaald is en je graag zelf zou vertalen, reserveer het dan voor u door een e-mail te sturen naar de Nederlandse mailing list op dutch@linuxfocus.org.

__info_de

LinuxFocus Übersetzerverzeichnis

Dies ist eine Übersichtsseite mit allen LinuxFocus Artikeln. Schon übersetzte Artikel haben einen hellen Hintergrund. Grau hinterlegte Artikel sind noch nicht übersetzt. Ein blau hinterlegter Artikel ist reserviert, aber noch nicht ganz fertig übersetzt.

Du kannst LinuxFocus unterstützen! Wenn Du einen Artikel siehst, der noch nicht übersetzt ist und Du Lust hast ihn zu übersetzen, dann schick einfach eine e-Mail an die Person, die am Ende der Seite als Verantwortlicher erwähnt ist und reservier Dir den Artikel.

__starttab1
__starttab3 __endtab
  __starttab2 Vertaald door Gecontroleerd

__dochead Linux Focus index page __enddoc __fin