#!/usr/bin/perl -w # # Script for translators that extract .sgml files into .sgml.po ones # # 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 strict; use File::Basename; use Getopt::Long; my $LANG = $ARGV[0]; #my $OUTFILE = "./tmp/$FILE.h"; my %string = (); my @elements; my @items; my $n=0; if (! $LANG){ print "Usage: update_po.pl LANGCODE\n"; exit; } else { $LANG .=".po"; } chdir ("./C"); if ( !(-d "./tmp") ) { mkdir ("./tmp", 0755) ; } my $comand=""; open FILES, "POTFILES.in.h"; while () { undef (%string); s/\n//g; my $Original_file = $_ ; s/.\///g; my $Converted_file = "./tmp/".$_.".h"; # print $Original_file."\n"; # print $Translated_file."\n"; print "Converting ".$Original_file."\n" ; system "rm -f $Converted_file"; &Convert ($Original_file); open OUT, ">>$Converted_file"; &addMessages; close OUT; $comand = "xgettext --default-domain=$Original_file "; $comand .="--directory=. --add-comments --keyword=_ --keyword=N_ "; $comand .="$Converted_file "; system ( $comand ); print ("Updating $Original_file.po\n"); system ("mv $Original_file.po ../$LANG/$Original_file.pot"); system ("cp ../$LANG/$Original_file.po ../$LANG/$Original_file.po.old"); system ("msgmerge ../$LANG/$Original_file.po.old ../$LANG/$Original_file.pot -o ../$LANG/$Original_file.po"); system ("msgfmt --statistics ../$LANG/$Original_file.po"); system ("rm -f ../$LANG/$Original_file.pot"); # print POTFILE $Converted_file."\n"; print ".\n"; } close FILES; system ("rm -rf ./tmp "); exit 0; sub Convert() { ## Reading the file open (IN, "<$_[0]") || die "can't open $_[0]: $!"; ### For translatable Sgml files ### while () { if ( //) ) { $string{$Salida} = []; } else { while () { $Salida .= $_ ; if ( /-->/ ) { last ; } } $string{$Salida} = []; } } elsif ( // ) { my $number_of_para = 1; my $Salida = $_ ; if ( /<\/para>/ ) { $string{$Salida} = []; } else { while () { if ( // ) { $number_of_para++; } $Salida .= $_ ; if ( /<\/para>/ ) { $number_of_para--; if ( $number_of_para==0) {last ; } } } $string{$Salida} = []; } } elsif ( // ) { my $Salida = $_ ; if ( /<\/title>/ ) { $string{$Salida} = []; } else { while (<IN>) { $Salida .= $_ ; if ( /<\/title>/ ) { last ; } } $string{$Salida} = []; } } elsif ( /<glossterm>/ ) { my $Salida = $_ ; if ( /<\/glossterm>/ ) { $string{$Salida} = []; } else { while (<IN>) { $Salida .= $_ ; if ( /<\/glossterm>/ ) { last ; } } $string{$Salida} = []; } } elsif ( /<guilabel>/ ) { my $Salida = $_ ; if ( /<\/guilabel>/ ) { $string{$Salida} = []; } else { while (<IN>) { $Salida .= $_ ; if ( /<\/guilabel>/ ) { last ; } } $string{$Salida} = []; } } } close (IN); } sub addMessages{ foreach my $theMessage (sort keys %string) { my ($tag) = $string{$theMessage} ; # Replace XML codes for special chars to # geniune gettext syntax #--------------------------------------- $theMessage =~ s/"/\\"/mg; $theMessage =~ s/\n/\\n\n/mg; # $theMessage =~ s/</</mg; # $theMessage =~ s/>/>/mg; if ($theMessage =~ /\n/) { #if ($tag) { print OUT "/* $tag */\n"; } @elements = split (/\n/, $theMessage); for ($n = 0; $n < @elements; $n++) { if ($n == 0) { print OUT "gchar *s = N_"; print OUT "(\"$elements[$n]\""; if ($n == @elements - 1) { print OUT ");\n"; } print OUT "\n"; } elsif ($n == @elements - 1) { print OUT " "; print OUT "\"$elements[$n]\");\n\n"; } elsif ($n > 0) { print OUT " "; print OUT "\"$elements[$n]\"\n"; } } } else { # if ($tag) { print OUT "/* $tag */\n"; } print OUT "gchar *s = N_(\"$theMessage\");\n"; } } } 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=b635301db8c6f484bb936fac7d40bcaa40602d11'>refs</a><a class='active' href='/~lantw44/cgit/freebsd-ports-gnome/log/devel/newt?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8'>log</a><a href='/~lantw44/cgit/freebsd-ports-gnome/tree/devel/newt?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&id=b635301db8c6f484bb936fac7d40bcaa40602d11'>tree</a><a href='/~lantw44/cgit/freebsd-ports-gnome/commit/devel/newt?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&id=b635301db8c6f484bb936fac7d40bcaa40602d11'>commit</a><a href='/~lantw44/cgit/freebsd-ports-gnome/diff/devel/newt?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&id=b635301db8c6f484bb936fac7d40bcaa40602d11'>diff</a><a href='/~lantw44/cgit/freebsd-ports-gnome/stats/devel/newt?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/devel/newt'> <input type='hidden' name='h' value='dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8'/><input type='hidden' name='id' value='b635301db8c6f484bb936fac7d40bcaa40602d11'/><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=b635301db8c6f484bb936fac7d40bcaa40602d11'>root</a>/<a href='/~lantw44/cgit/freebsd-ports-gnome/log/devel?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&id=b635301db8c6f484bb936fac7d40bcaa40602d11'>devel</a>/<a href='/~lantw44/cgit/freebsd-ports-gnome/log/devel/newt?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&id=b635301db8c6f484bb936fac7d40bcaa40602d11'>newt</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/devel/newt?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&id=b635301db8c6f484bb936fac7d40bcaa40602d11&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/devel/newt?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&id=fcc10a3b244bbef243a0d0b8b8564eaa336dfe97'>Update to 0.52.19.</a></td><td>mat</td><td><span title='2016-04-18 22:07:04 +0800'>2016-04-18</span></td><td>5</td><td><span class='deletions'>-12</span>/<span class='insertions'>+12</span></td></tr> <tr><td class='commitgraph'>* </td><td><a href='/~lantw44/cgit/freebsd-ports-gnome/commit/devel/newt?h=dependabot/npm_and_yarn/devel/electron6/files/ini-1.3.8&id=148314483d3098c0d6a33944f1190842e671502f'>Remove ${PORTSDIR}/ from dependencies, categories d, e, f, and g.</a></td><td>mat</td><td><span title='2016-04-01 22:00:51 +0800'>2016-04-01</span>