#!/usr/bin/perl -w # # Script that translates .sgml files using the .po files generated from # the script update_po.pl # # Copyright (C) 2001 Héctor García Álvarez. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of the # License, or (at your option) any later version. # # This script is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this library; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # # Authors: Héctor García Álvarez ## Loaded modules use File::Basename; use Getopt::Long; my $LANG = $ARGV[0]; my %string; my $texto_original=""; my $texto_traducido=""; if (! $LANG){ print "Usage: update_translation.pl LANGCODE\n"; exit; } chdir ("./C"); ## Reading the po file #print "Loading ".$LANG.".po\n"; #&load_translated_strings ($LANG.".po"); ## Checking for the lang dir if ( !(-d "../".$LANG) ) { mkdir ("../".$LANG, 0755) ; } open FILES, ") { undef %string; s/\n//g; $Original_file = $_ ; s/.\///g; $Translated_file = "../".$LANG."/".$_; # print $Original_file."\n"; # print $Translated_file."\n"; &load_translated_strings ("../".$LANG.".po/".$_.".po"); print "Translating ".$Original_file ; system "rm -f $Translated_file"; &translate_file ($Translated_file , $Original_file); print ".\n"; } close FILES; exit 0; sub load_translated_strings () { my $FILE=$_[0]; open (IN, "<$FILE") || die "I can't find $FILE"; while () { if ( /#: /) { &original; &traduccion; # print "Original \n##".$texto_original."##\n"; # print "Traducción \n##".$texto_traducido."##\n"; $string{$texto_original} = $texto_traducido; } } close (IN); } sub translate_file () { my $OUTFILE=$_[0]; my $INFILE=$_[1]; open OUT, ">>$OUTFILE"; open (IN, "<$INFILE") || die "can't open $INFILE: $!"; while () { my $imprimir = 0; if ( //) ) { while () { $Salida .= $_ ; if ( /-->/ ) { last ; } } } $imprimir = 1; } elsif ( // ) { my $number_of_para = 1; $Salida = $_ ; if ( !(/<\/para>/) ) { while () { if ( // ) { $number_of_para++; } $Salida .= $_ ; if ( /<\/para>/ ) { $number_of_para--; if ( $number_of_para==0) {last ; } } } } $imprimir = 1; } elsif ( // ) { $Salida = $_ ; if ( !(/<\/title>/) ) { while (<IN>) { $Salida .= $_ ; if ( /<\/title>/ ) { last ; } } } $imprimir = 1; } elsif ( /<glossterm>/ ) { $Salida = $_ ; if ( !(/<\/glossterm>/) ) { while (<IN>) { $Salida .= $_ ; if ( /<\/glossterm>/ ) { last ; } } } $imprimir = 1; } elsif ( /<guilabel>/ ) { $Salida = $_ ; if ( !(/<\/guilabel>/) ) { while (<IN>) { $Salida .= $_ ; if ( /<\/guilabel>/ ) { last ; } } } $imprimir = 1; } if ( $imprimir == 0 ) { print (OUT $_); } else { my $impreso=0; foreach my $theMessage (sort keys %string) { if (!($theMessage cmp $Salida)) { my $tag = $string{$Salida} ; if ( $tag cmp "") { $tag =~ s/\\"/"/mg ; print (OUT $tag); } else { print (OUT $Salida); } $impreso=1; } } if ( $impreso == 0) { print "No lo encuentro\n##".$Salida."##\n"; $impreso=0; } $imprimir = 0; } } close IN; close OUT; } #exit 0; sub original () { my $tmp = ""; while (<IN>) { if ( !(/^#: /) ) { if ( /msgid ""/) { s/msgid ""\n//; } if ( /msgstr/) { $tmp =~ s/\\n/\n/sg ; $tmp =~ s/\\t/\t/sg ; $tmp =~ s/\\"/"/sg ; $texto_original = $tmp; last ; } s/msgid "//; s/\s*"// ; s/"\n// ; s/\n// ; $tmp .= $_; } } } sub traduccion () { my $tmp = ""; my $first = 0; if ( /msgstr "/) { if ( /msgstr ""/) { $tmp = ""; $first = 1; } else { $tmp = $_; $tmp =~ s/msgstr "//; $tmp =~ s/"\n// ; } } while (<IN>) { if ( !($_ cmp "\n") ) { $tmp =~ s/\\n/\n/sg ; $tmp =~ s/\\t/\t/sg ; $tmp =~ s/\"/"/sg ; if ( $first == 1 ) { $texto_traducido = "" ; } else { $texto_traducido = $tmp; } last ; } $first = 0; s/msgstr "//; s/"\n// ; s/\s*"// ; $tmp .= $_; } if ( eof IN ) { $tmp =~ s/\\n/\n/sg ; $tmp =~ s/\\t/\t/sg ; $tmp =~ s/\"/"/sg ; $texto_traducido = $tmp; } } > <option value='mate-1.22'>mate-1.22</option> </select> <input type='submit' value='switch'/></form></td></tr> <tr><td class='sub'>FreeBSD GNOME current development ports (https://github.com/freebsd/freebsd-ports-gnome)</td><td class='sub right'></td></tr></table> <table class='tabs'><tr><td> <a href='/~lantw44/cgit/freebsd-ports-gnome/about/?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8'>about</a><a href='/~lantw44/cgit/freebsd-ports-gnome/?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8'>summary</a><a href='/~lantw44/cgit/freebsd-ports-gnome/refs/?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&id=2ca472d65e16831953390c01e42ec9a0710487e7'>refs</a><a class='active' href='/~lantw44/cgit/freebsd-ports-gnome/log/textproc/rubygem-yard?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8'>log</a><a href='/~lantw44/cgit/freebsd-ports-gnome/tree/textproc/rubygem-yard?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&id=2ca472d65e16831953390c01e42ec9a0710487e7'>tree</a><a href='/~lantw44/cgit/freebsd-ports-gnome/commit/textproc/rubygem-yard?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&id=2ca472d65e16831953390c01e42ec9a0710487e7'>commit</a><a href='/~lantw44/cgit/freebsd-ports-gnome/diff/textproc/rubygem-yard?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&id=2ca472d65e16831953390c01e42ec9a0710487e7'>diff</a><a href='/~lantw44/cgit/freebsd-ports-gnome/stats/textproc/rubygem-yard?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8'>stats</a></td><td class='form'><form class='right' method='get' action='/~lantw44/cgit/freebsd-ports-gnome/log/textproc/rubygem-yard'> <input type='hidden' name='h' value='dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8'/><input type='hidden' name='id' value='2ca472d65e16831953390c01e42ec9a0710487e7'/><select name='qt'> <option value='grep'>log msg</option> <option value='author'>author</option> <option value='committer'>committer</option> <option value='range'>range</option> </select> <input class='txt' type='search' size='10' name='q' value=''/> <input type='submit' value='search'/> </form> </td></tr></table> <div class='path'>path: <a href='/~lantw44/cgit/freebsd-ports-gnome/log/?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&id=2ca472d65e16831953390c01e42ec9a0710487e7'>root</a>/<a href='/~lantw44/cgit/freebsd-ports-gnome/log/textproc?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&id=2ca472d65e16831953390c01e42ec9a0710487e7'>textproc</a>/<a href='/~lantw44/cgit/freebsd-ports-gnome/log/textproc/rubygem-yard?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&id=2ca472d65e16831953390c01e42ec9a0710487e7'>rubygem-yard</a></div><div class='content'><table class='list nowrap'><tr class='nohover'><th></th><th class='left'>Commit message (<a href='/~lantw44/cgit/freebsd-ports-gnome/log/textproc/rubygem-yard?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&id=2ca472d65e16831953390c01e42ec9a0710487e7&showmsg=1'>Expand</a>)</th><th class='left'>Author</th><th class='left'>Age</th><th class='left'>Files</th><th class='left'>Lines</th></tr> <tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/freebsd-ports-gnome/commit/textproc/rubygem-yard?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&id=def81aa6a10d1a704df17bd6a66c671e37ade907'>Update to 0.9.16</a></td><td>sunpoet</td><td><span title='2018-08-14 02:20:20 +0800'>2018-08-14</span></td><td>2</td><td><span class='deletions'>-4</span>/<span class='insertions'>+4</span></td></tr> <tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/freebsd-ports-gnome/commit/textproc/rubygem-yard?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&id=4a83a5819ef066c0df9ff31becc834f43f4af18f'>Update to 0.9.15</a></td><td>sunpoet</td><td><span title='2018-07-30 03:23:21 +0800'>2018-07-30</span></td><td>2</td><td><span class='deletions'>-4</span>/<span class='insertions'>+4</span></td></tr> <tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/freebsd-ports-gnome/commit/textproc/rubygem-yard?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&id=35420abdbd466a3af38f0b9e061a316e35c85339'>Update to 0.9.14</a></td><td>sunpoet</td><td><span title='2018-06-04 02:17:12 +0800'>2018-06-04</span></td><td>2</td><td><span class='deletions'>-4</span>/<span class='insertions'>+4</span></td></tr> <tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/freebsd-ports-gnome/commit/textproc/rubygem-yard?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&id=ab480a80c2f7dd8987fdccdd42479abd05da635e'>Update to 0.9.13</a></td><td>sunpoet</td><td><span title='2018-05-31 03:48:28 +0800'>2018-05-31</span></td><td>2</td><td><span class='deletions'>-4</span>/<span class='insertions'>+4</span></td></tr> <tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/freebsd-ports-gnome/commit/textproc/rubygem-yard?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&id=ab9bc8a82bb943258bd77db03ccba312c93c016d'>Update to 0.9.12</a></td><td>sunpoet</td><td><span title='2017-11-28 08:51:29 +0800'>2017-11-28</span></td><td>2</td><td><span class='deletions'>-4</span>/<span class='insertions'>+4</span></td></tr> <tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/freebsd-ports-gnome/commit/textproc/rubygem-yard?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&id=e42903307083b662881f7f62edfae92b59323c96'>Update to 0.9.11</a></td><td>sunpoet</td><td><span title='2017-11-27 07:19:35 +0800'>2017-11-27</span></td><td>2</td><td><span class='deletions'>-4</span>/<span class='insertions'>+4</span></td></tr> <tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/freebsd-ports-gnome/commit/textproc/rubygem-yard?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&id=6466b1b1342f22f1c517cda31d73dc1ff2a6a3d4'>Update to 0.9.10</a></td><td>sunpoet</td><td><span title='2017-11-20 21:22:13 +0800'>2017-11-20</span></td><td>2</td><td><span class='deletions'>-4</span>/<span class='insertions'>+4</span></td></tr> <tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/freebsd-ports-gnome/commit/textproc/rubygem-yard?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&id=207b33cbbff530aa1c3fab3b8966805102652833'>Update to 0.9.9</a></td><td>sunpoet</td><td><span title='2017-04-24 23:17:23 +0800'>2017-04-24</span></td><td>2</td><td><span class='deletions'>-4</span>/<span class='insertions'>+4</span></td></tr> <tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/freebsd-ports-gnome/commit/textproc/rubygem-yard?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&id=5008808c4694d40f9cd3668c32a12e5465a763d3'>Update to 0.9.8</a></td><td>sunpoet</td><td><span title='2017-01-15 01:19:34 +0800'>2017-01-15</span></td><td>2</td><td><span class='deletions'>-4</span>/<span class='insertions'>+4</span></td></tr> <tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/freebsd-ports-gnome/commit/textproc/rubygem-yard?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&id=5f052716c90e9100c777b6efe6c1fb5290c7a1a9'>Update to 0.9.7</a></td><td>sunpoet</td><td><span title='2017-01-11 02:05:43 +0800'>2017-01-11</span></td><td>2</td><td><span class='deletions'>-4</span>/<span class='insertions'>+4</span></td></tr> <tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/freebsd-ports-gnome/commit/textproc/rubygem-yard?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&id=10d7bdd26c56088acf1cd796498c32e36688a79e'>Update to 0.9.6</a></td><td>sunpoet</td><td><span title='2017-01-09 04:43:06 +0800'>2017-01-09</span></td><td>2</td><td><span class='deletions'>-4</span>/<span class='insertions'>+4</span></td></tr> <tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/freebsd-ports-gnome/commit/textproc/rubygem-yard?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&id=97599de05b0f43b603557a2aedf78a564b688fef'>Update to 0.9.5</a></td><td>sunpoet</td><td><span title='2017-01-02 05:41:15 +0800'>2017-01-02</span></td><td>2</td><td><span class='deletions'>-3</span>/<span class='insertions'>+4</span></td></tr> <tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/freebsd-ports-gnome/commit/textproc/rubygem-yard?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&id=17514e0351a1b7ce99e34ae1192a37395cdffec7'>Convert USES=gem:autoplist to USES=gem since autoplist is default</a></td><td>swills</td><td><span title='2016-04-28 05:57:31 +0800'>2016-04-28</span></td><td>1</td><td><span class='deletions'>-1</span>/<span class='insertions'>+1</span></td></tr>