3 # Script that translates .sgml files using the .po files generated from
4 # the script update_po.pl
6 # Copyright (C) 2001 Héctor García Álvarez.
8 # This library is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License as
10 # published by the Free Software Foundation; either version 2 of the
11 # License, or (at your option) any later version.
13 # This script is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this library; if not, write to the Free Software
20 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 # Authors: Héctor García Álvarez <hector@scouts-es.org>
32 my $texto_original="";
33 my $texto_traducido="";
36 print "Usage: update_translation.pl LANGCODE\n";
42 ## Reading the po file
43 #print "Loading ".$LANG.".po\n";
44 #&load_translated_strings ($LANG.".po");
46 ## Checking for the lang dir
47 if ( !(-d
"../".$LANG) ) { mkdir ("../".$LANG, 0755) ; }
49 open FILES
, "<POTFILES.in" ;
55 $Translated_file = "../".$LANG."/".$_;
56 # print $Original_file."\n";
57 # print $Translated_file."\n";
58 &load_translated_strings
("../".$LANG.".po/".$_.".po");
59 print "Translating ".$Original_file ;
60 system "rm -f $Translated_file";
61 &translate_file
($Translated_file , $Original_file);
71 sub load_translated_strings
()
74 open (IN
, "<$FILE") || die "I can't find $FILE";
80 # print "Original \n##".$texto_original."##\n";
81 # print "Traducción \n##".$texto_traducido."##\n";
82 $string{$texto_original} = $texto_traducido;
93 open OUT
, ">>$OUTFILE";
94 open (IN
, "<$INFILE") || die "can't open $INFILE: $!";
103 if ( /-->/ ) { last ; }
109 my $number_of_para = 1;
111 if ( !(/<\/para
>/) ) {
113 if ( /<para>/ ) { $number_of_para++; }
117 if ( $number_of_para==0) {last ; }
123 elsif ( /<title>/ ) {
125 if ( !(/<\/title
>/) ) {
128 if ( /<\/title
>/ ) { last ; }
133 elsif ( /<glossterm>/ ) {
135 if ( !(/<\/glossterm
>/) ) {
138 if ( /<\/glossterm
>/ ) { last ; }
143 elsif ( /<guilabel>/ ) {
145 if ( !(/<\/guilabel
>/) ) {
148 if ( /<\/guilabel
>/ ) { last ; }
153 if ( $imprimir == 0 ) { print (OUT
$_); }
156 foreach my $theMessage (sort keys %string) {
157 if (!($theMessage cmp $Salida)) {
158 my $tag = $string{$Salida} ;
170 if ( $impreso == 0) {
171 print "No lo encuentro\n##".$Salida."##\n";
187 if ( /msgid ""/) { s/msgid ""\n//; }
189 $tmp =~ s/\\n/\n/sg ;
190 $tmp =~ s/\\t/\t/sg ;
192 $texto_original = $tmp;
214 $tmp =~ s/msgstr "//;
220 if ( !($_ cmp "\n") ) {
221 $tmp =~ s/\\n/\n/sg ;
222 $tmp =~ s/\\t/\t/sg ;
224 if ( $first == 1 ) { $texto_traducido = "" ; }
225 else { $texto_traducido = $tmp; }
235 $tmp =~ s/\\n/\n/sg ;
236 $tmp =~ s/\\t/\t/sg ;
238 $texto_traducido = $tmp;