mail[Wesnoth-commits] r24987 - /branches/1.4/utils/wmlxgettext


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by benoit . timbert on March 22, 2008 - 18:17:
Author: noyga
Date: Sat Mar 22 18:08:17 2008
New Revision: 24987

URL: http://svn.gna.org/viewcvs/wesnoth?rev=24987&view=rev
Log:
Apply a patch from caslav.ilic : Fix the extraction of info variables when 
the value is quoted.

Modified:
    branches/1.4/utils/wmlxgettext

Modified: branches/1.4/utils/wmlxgettext
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/1.4/utils/wmlxgettext?rev=24987&r1=24986&r2=24987&view=diff
==============================================================================
--- branches/1.4/utils/wmlxgettext (original)
+++ branches/1.4/utils/wmlxgettext Sat Mar 22 18:08:17 2008
@@ -20,7 +20,14 @@
 our $module = dirname ($0) . "/wmltrans.pm";
 eval "require \"$module\";";
 
-## extract strings with their refs into %messages
+## extract strings with their refs and node info into %messages
+
+sub possible_node_info {
+  my ($nodeinfostack, $field, $value) = @_;
+  if ($field =~ m/\b(speaker|role|description|condition|type|race)\b/) {
+    push @{$nodeinfostack->[-1][2]}, "$field=$value";
+  }
+}
 
 our ($str,$translatable,$line,%messages,%nodeinfo);
 chdir $toplevel;
@@ -54,15 +61,22 @@
     if (!defined $str and m/^(?:[^\"]*?)((?:_\s*)?)\"([^\"]*)\"(.*)/) {
       # single-line quoted string
 
-       # if translatable and in the requested domain
-      if ($1 ne '' and $domainstack[0] eq $domain) {
+      $translatable = ($1 ne '');
+      my $rest = $3;
+
+      # if translatable and in the requested domain
+      if ($translatable and $domainstack[0] eq $domain) {
         my $msg = raw2postring($2);
         push @{$messages{$msg}}, "$file:$.";
         push @{$nodeinfostack[-1][1]}, $msg if $valid_wml;
+
+      } elsif (not $translatable and m/(\S+)\s*=\s*\"([^\"]*)\"/) {
+        # may be a piece of node info to extract
+        possible_node_info(\@nodeinfostack, $1, $2) if $valid_wml;
       }
 
       # process remaining of the line
-      $_ = $3 . "\n";
+      $_ = $rest . "\n";
       redo LINE;
 
     } elsif (!defined $str and m/^(?:[^\"]*?)((?:_\s*)?)\s*\"([^\"]*)/) {
@@ -99,10 +113,7 @@
     } elsif (m/(\S+)\s*=\s*(.*?)\s*$/) {
       # single-line non-quoted string
       die "nested string in $file" if defined $str;
-      my ($field, $value) = ($1, $2);
-      if ($field =~ m/\b(speaker|role|description|condition|type|race)\b/) {
-        push @{$nodeinfostack[-1][2]}, "$field=$value" if $valid_wml;
-      }
+      possible_node_info(\@nodeinfostack, $1, $2) if $valid_wml;
 
 ### probably not needed ###
 #      # magic handling of weapon descriptions
@@ -219,7 +230,7 @@
       for my $info (@{$nodeinfo{$key}}) {
         my ($name, $data) = @{$info};
         my $desc = join(", ", @{$data});
-        my $nodestr = $desc ? "$name: $desc" : $name;
+        my $nodestr = $desc ? "[$name]: $desc" : "[$name]";
         # Add only unique node info strings.
         if (not defined $added{$nodestr}) {
             $added{$nodestr} = 1;




Related Messages


Powered by MHonArc, Updated Sat Mar 22 18:22:05 2008