File: intltool-update.patch

package info (click to toggle)
intltool-debian 0.35.0%2B20060710.6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 168 kB
  • sloc: perl: 2,744; makefile: 23
file content (119 lines) | stat: -rw-r--r-- 3,362 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
Index: intltool-update.in.in
===================================================================
RCS file: /cvs/gnome/intltool/intltool-update.in.in,v
retrieving revision 1.123
diff -u -r1.123 intltool-update.in.in
--- intltool-update.in.in	10 May 2006 18:36:53 -0000	1.123
+++ intltool-update.in.in	10 Jul 2006 19:40:56 -0000
@@ -162,7 +162,7 @@
 	&GeneratePOTemplate;
     }
     &POFile_Update ($lang, $OUTPUT_FILE);
-    &Console_Write_TranslationStatus ($lang, $OUTPUT_FILE);
+    &Console_Write_TranslationStatus ($lang, $OUTPUT_FILE) if $VERBOSE;
 } 
 else 
 {
@@ -281,20 +281,6 @@
 sub TextFile_DetermineEncoding ($) 
 {
     my $gettext_code="ASCII"; # All files are ASCII by default
-    my $filetype=`file $_ | cut -d ' ' -f 2`;
-
-    if ($? eq "0")
-    {
-	if ($filetype =~ /^(ISO|UTF)/)
-	{
-	    chomp ($gettext_code = $filetype);
-	}
-	elsif ($filetype =~ /^XML/)
-	{
-	    $gettext_code="UTF-8"; # We assume that .glade and other .xml files are UTF-8
-	}
-    }
-
     return $gettext_code;
 }
 
@@ -714,11 +700,11 @@
     close OUTFILE;
     close INFILE;
 
-    unlink "$MODULE.pot";
+    unlink "$MODULE.pot-update";
     my @xgettext_argument=("$XGETTEXT",
 			   "--add-comments",
 			   "--directory\=\.",
-			   "--output\=$MODULE\.pot",
+			   "--output\=$MODULE\.pot-update",
 			   "--files-from\=\.\/POTFILES\.in\.temp");
     my $XGETTEXT_KEYWORDS = &FindPOTKeywords;
     push @xgettext_argument, $XGETTEXT_KEYWORDS;
@@ -741,14 +727,23 @@
 
     if (! $command_failed)
     {
-	if (! -e "$MODULE.pot")
+	if (! -e "$MODULE.pot-update")
 	{
-	    print "None of the files in POTFILES.in contain strings marked for translation.\n" if $VERBOSE;
+	    print STDERR "None of the files in POTFILES.in contain strings marked for translation.\n";
+	}
+	if (-e "$MODULE.pot")
+	{
+	    RemovePOHeader("$MODULE.pot", "$MODULE.1po");
+	    RemovePOHeader("$MODULE.pot-update", "$MODULE.2po");
+	    system("cmp", "-s", "$MODULE.1po", "$MODULE.2po");
+	    rename("$MODULE.pot-update", "$MODULE.pot") if $?;
+	    unlink "$MODULE.1po", "$MODULE.2po", "$MODULE.pot-update";
 	}
 	else
 	{
-	    print "Wrote $MODULE.pot\n" if $VERBOSE;
+	    rename("$MODULE.pot-update", "$MODULE.pot");
 	}
+	print "Wrote $MODULE.pot\n" if $VERBOSE;
     }
     else
     {
@@ -764,7 +759,7 @@
 	else
 	{
 	    print STDERR "$xgettext_error_msg";
-	    if (-e "$MODULE.pot")
+	    if (-e "$MODULE.pot-update")
 	    {
 		# is this possible?
 		print STDERR "ERROR: xgettext failed but still managed to generate PO template file.\n".
@@ -780,6 +775,22 @@
     }
 }
 
+sub RemovePOHeader
+{
+    my ($infile, $outfile) = @_;
+    my $first = 1;
+
+    open (IN, "< $infile") || die "file $infile does not exist";
+    open (OUT, "> $outfile") || die "Unable to write into $outfile: $!";
+    local $/ = "\n\n";
+    while (<IN>) {
+        next if m/^msgid ""\nmsgstr/m;
+        print OUT;
+    }
+    close IN;
+    close OUT;
+}
+
 sub POFile_Update
 {
     -f "$MODULE.pot" or die "$PROGRAM: $MODULE.pot does not exist.\n";
@@ -793,7 +804,7 @@
     $outfile = "$SRCDIR/$lang.po" if ($outfile eq "");
 
     # I think msgmerge won't overwrite old file if merge is not successful
-    system ("$MSGMERGE", "-o", $outfile, $infile, "$MODULE.pot");
+    system ("$MSGMERGE", "-q", "-o", $outfile, $infile, "$MODULE.pot");
 }
 
 sub Console_WriteError_NotExisting