File: intltool-merge.patch

package info (click to toggle)
intltool-debian 0.30+20040213
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 132 kB
  • ctags: 83
  • sloc: perl: 1,998; makefile: 41
file content (81 lines) | stat: -rw-r--r-- 2,636 bytes parent folder | download
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
Index: intltool-merge.in.in
===================================================================
RCS file: /cvs/gnome/intltool/intltool-merge.in.in,v
retrieving revision 1.92
diff -u -r1.92 intltool-merge.in.in
--- intltool-merge.in.in	4 Feb 2004 19:34:54 -0000	1.92
+++ intltool-merge.in.in	31 Mar 2004 22:49:52 -0000
@@ -993,6 +993,20 @@
 {
     my $source;
 
+    eval 'require XML::Parser';
+    die "You must have XML::Parser installed to run $0\n\n"
+        if($@);
+
+    ## Add dir to own perl modules
+    my $dir = dirname($0);
+    push @INC, "@EXPANDED_DATADIR@/@PACKAGE@";
+    push @INC, "$dir/modules";
+    push @INC, "$dir/intltool-modules";
+
+    eval 'require XML::Parser::Style::OrigTree';
+    die "The OrigTree module doesn't seem to be properly installed $0\n\n"
+        if($@);
+
     if ($MULTIPLE_OUTPUT) {
         for my $lang (sort keys %po_files_by_lang) {
 	    if ( ! -e $lang ) {
@@ -1198,13 +1212,15 @@
 
     open OUTPUT, ">${OUTFILE}" or die;
 
+    #  Remove comments
+    $source =~ s/^#[^\n]*(\n|$)//s;
+    $source =~ s/\n#[^\n]*//g;
     while ($source =~ /(^|\n+)(_*)([^:\s]+)(:[ \t]*)(.*?)(?=\n[\S\n]|$)/sg)
     {
 	    my $sep = $1;
 	    my $non_translated_line = $3.$4;
 	    my $string = $5;
 	    my $underscore = length($2);
-	    next if $underscore eq 0 && $non_translated_line =~ /^#/;
 	    #  Remove [] dummy strings
 	    my $stripped = $string;
 	    $stripped =~ s/\[\s[^\[\]]*\],/,/g if $underscore eq 2;
@@ -1236,6 +1252,9 @@
 	                #  $translation may also contain [] dummy
                         #  strings, mostly to indicate an empty string
 	                $translation =~ s/\[\s[^\[\]]*\]$//;
+
+	                #  Escape commas
+			$translation =~ s/,/\\,/g if $underscore eq 2;
                         
                         if ($first) 
                         {
@@ -1267,6 +1286,7 @@
 
                         #  To fix some problems with Text::Wrap::wrap
                         $str_translated =~ s/(\n )+\n/\n .\n/g;
+                        $str_translated =~ s/(^|\n)(  +)\n( \S{$Text::Wrap::columns})/$1$2$3/g;
                     }
                     next unless $is_translated;
 
@@ -1299,7 +1319,16 @@
     my $type = shift;
     my $text = shift;
     $text =~ s/^[ \t]//mg;
-    return (split(/, */, $text, 0)) if $type ne 1;
+    if ($type ne 1)
+    {
+        my @values = ();
+        for my $value (split(/(?<!\\), */, $text, 0))
+        {
+            $value =~ s/\\,/,/g;
+            push @values, $value;
+        }
+        return @values;
+    }
     return ($text) if $text !~ /\n/;
 
     $text =~ s/([^\n]*)\n//;