[Po4a-devel][CVS] po4a po4a-gettextize,1.22,1.23 po4a-updatepo,1.22,1.23

Jordi Vilalta po4a-devel@lists.alioth.debian.org
Sun, 08 Aug 2004 06:48:17 +0000


Update of /cvsroot/po4a/po4a
In directory haydn:/tmp/cvs-serv26623

Modified Files:
	po4a-gettextize po4a-updatepo 
Log Message:
These two seem to be correct. Now let's mess TransTractor up  ó_ò


Index: po4a-updatepo
===================================================================
RCS file: /cvsroot/po4a/po4a/po4a-updatepo,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- po4a-updatepo	19 Jul 2004 10:21:12 -0000	1.22
+++ po4a-updatepo	8 Aug 2004 06:48:15 -0000	1.23
@@ -144,6 +144,7 @@
 # Parse our options
 my (@masterfiles,@pofiles);
 my ($help,$help_fmt,$verbose,$debug,$format,@options);
+my $mastchar;
 GetOptions('help|h'      => \$help,
   	   'help-format' => \$help_fmt,
 	   
@@ -151,6 +152,8 @@
 	   'po|p=s'      => \@pofiles,
 	   'format|f=s'  => \$format,
 
+           'master-charset|M=s' => \$mastchar,
+
            'option|o=s'    => \@options,
     
 	   'verbose|v'   => \$verbose,
@@ -192,18 +195,28 @@
 
 print STDERR gettext("Parse input files... ") if $verbose;    
 
-$doc->process('file_in_name' => \@masterfiles,
-	      'po_out_name'  => $pot_filename,
-	      'debug'        => $debug,
-	      'verbose'      => $verbose);
+$doc->{TT}{utf_mode} = 1;
 
-print STDERR gettext("done.")."\n" if $verbose;    
+$doc->process('file_in_name'    => \@masterfiles,
+	      'file_in_charset' => $mastchar,
+	      'po_out_name'     => $pot_filename,
+	      'debug'           => $debug,
+	      'verbose'         => $verbose);
+
+print STDERR gettext("done.")."\n" if $verbose;
 
 
 while (my $po_filename=shift @pofiles) {
     if (-e $po_filename) {
 	print STDERR sprintf(gettext("Updating %s:"),$po_filename) 
 	    if $verbose;    
+	# Recode the po file if needed before merging
+	unless ($doc->{TT}{ascii_input}) {
+	    my $oldpo = Locale::Po4a::Po->new();
+	    $oldpo->read($po_filename);
+	    $oldpo->to_utf();
+	    $oldpo->write($po_filename);
+	}
 	system ("msgmerge","-U",$po_filename,$pot_filename) == 0 ||
 	    die sprintf(gettext("Error while running msgmerge: %s"),$!)."\n";
 	system "msgfmt --statistics -v -o /dev/null $po_filename" 

Index: po4a-gettextize
===================================================================
RCS file: /cvsroot/po4a/po4a/po4a-gettextize,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- po4a-gettextize	19 Jul 2004 10:21:12 -0000	1.22
+++ po4a-gettextize	8 Aug 2004 06:48:15 -0000	1.23
@@ -158,18 +158,22 @@
 
 my ($pofile)=('-');
 my ($masterfile,$locfile,$help_fmt,$help,$type,$debug,$verbose,@options);
+my ($mastchar,$locchar);
 Getopt::Long::config('bundling', 'no_getopt_compat', 'no_auto_abbrev');
 GetOptions(
         'help|h'        => \$help,
 	'help-format'   => \$help_fmt,
-        
+
         'master|m=s'    => \$masterfile,
 	'localized|l=s' => \$locfile,
         'po|p=s'        => \$pofile,
         'format|f=s'    => \$type,
 
+	'master-charset|M=s'    => \$mastchar,
+	'localized-charset|L=s' => \$locchar,
+
         'option|o=s'    => \@options,
-    
+
         'verbose|v'     => \$verbose,
         'debug|d'       => \$debug,
         'version|V'     => \&show_version
@@ -202,8 +206,10 @@
 my ($mastertt,$transtt)=(Locale::Po4a::Chooser::new($type,%options),
 			 Locale::Po4a::Chooser::new($type,%options));
 
-# Parse master file
+# Parse master file forcing conversion to utf if it's not in ascii
 $mastertt->read($masterfile);
+$mastertt->{TT}{utf_mode} = 1;
+$mastertt->{TT}{file_in_charset} = $mastchar;
 $mastertt->parse;
 
 
@@ -214,6 +220,9 @@
   # We have to merge two transtractor files
 
   $transtt->read($locfile);
+  # We force the conversion to utf if the master document wasn't in ascii
+  $transtt->{TT}{utf_mode} = !$mastertt->{TT}{ascii_input};
+  $transtt->{TT}{file_in_charset} = $locchar;
   $transtt->parse;
 
   my $mergedpo = Locale::Po4a::Po->gettextize($mastertt->getpoout(),