[Po4a-devel][CVS] po4a/lib/Locale/Po4a Po.pm,1.20,1.21

Jordi Vilalta po4a-devel@lists.alioth.debian.org
Sun, 08 Aug 2004 11:31:09 +0000


Update of /cvsroot/po4a/po4a/lib/Locale/Po4a
In directory haydn:/tmp/cvs-serv6782

Modified Files:
	Po.pm 
Log Message:
Gettextization selects a character set for the resulting po depending on how
are the original and the translation encoded.


Index: Po.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/Po.pm,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- Po.pm	8 Aug 2004 06:30:56 -0000	1.20
+++ Po.pm	8 Aug 2004 11:31:07 -0000	1.21
@@ -81,6 +81,7 @@
 my %debug=('canonize'	=> 0,
            'quote'	=> 0,
            'escape'	=> 0,
+           'encoding'   => 1,
            'filter'     => 1);
 
 =head1 Functions about whole message catalogs
@@ -300,7 +301,19 @@
 	        "po4a gettextize: A possible cause is that a text dupplicated in the original is not translated the same way each time. Remove one of the translations, and you're fine."),
 		    $poorig->count_entries() , $potrans->count_entries())."\n";
     }
-    
+
+    if ( $poorig->get_charset =~ /^utf-8$/i ) {
+	$potrans->to_utf;
+	$pores->set_charset("utf-8");
+    } else {
+	$pores->set_charset($potrans->get_charset);
+    }
+    print "Po character sets:\n".
+	"  original=".$poorig->get_charset."\n".
+	"  translated=".$potrans->get_charset."\n".
+	"  result=".$pores->get_charset."\n"
+	    if $debug{'encoding'};
+
     for (my ($o,$t)=(0,0) ;
 	 $o<$poorig->count_entries() && $t<$potrans->count_entries();
 	 $o++,$t++) {
@@ -568,8 +581,8 @@
     my $charset = $this->get_charset();
 
     unless ($charset eq "CHARSET" or
-	    $charset eq "ascii" or
-	    $charset eq "utf-8") {
+	    $charset =~ /^ascii$/i or
+	    $charset =~ /^utf-8$/i) {
 	foreach my $msgid ( keys %{$this->{po}} ) {
 	    Encode::from_to($this->{po}{$msgid}{'msgstr'}, $charset, "utf-8");
 	}