wesnoth-cvs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Wesnoth-cvs-commits] wesnoth/utils wmlxgettext


From: Yann Dirson
Subject: [Wesnoth-cvs-commits] wesnoth/utils wmlxgettext
Date: Sun, 14 Nov 2004 17:25:30 -0500

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Yann Dirson <address@hidden>    04/11/14 22:19:49

Modified files:
        utils          : wmlxgettext 

Log message:
        make wmlxgettext output strings sorted as "msgcat --sort-by-file" would 
do

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/utils/wmlxgettext.diff?tr1=1.11&tr2=1.12&r1=text&r2=text

Patches:
Index: wesnoth/utils/wmlxgettext
diff -u wesnoth/utils/wmlxgettext:1.11 wesnoth/utils/wmlxgettext:1.12
--- wesnoth/utils/wmlxgettext:1.11      Tue Nov  9 00:34:35 2004
+++ wesnoth/utils/wmlxgettext   Sun Nov 14 22:19:49 2004
@@ -16,6 +16,8 @@
 our $module = dirname ($0) . "/wmltrans.pm";
 eval "require \"$module\";";
 
+## extract strings with their refs into %messages
+
 our ($str,$translatable,$line,%messages);
 chdir $toplevel;
 foreach my $file (@ARGV) {
@@ -89,18 +91,37 @@
   close FILE;
 }
 
+
+## index strings by their location in the source so we can sort them
+
+our @revmessages;
+foreach my $key (keys %messages) {
+  foreach my $line (@{$messages{$key}}) {
+    my ($file, $lineno) = split /:/, $line;
+    push @revmessages, [ $file, $lineno, $key ];
+  }
+}
+
+# sort them
address@hidden = sort { $a->[0] cmp $b->[0] or $a->[1] <=> $b->[1] } 
@revmessages;
+
+
 ## output
 
 my $date = strftime "%F %R%z", localtime();
 
 print <<EOH
-#, fuzzy
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\\n"
 "Report-Msgid-Bugs-To: http://bugs.wesnoth.org/\\n";
 "POT-Creation-Date: $date\\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n"
+EOH
+;
+# we must break this string to avoid triggering a bug in some po-mode
+# installations, at save-time for this file
+print "\"PO-Revision-Date: YEAR-MO-DA ", "HO:MI+ZONE\\n\"\n";
+print <<EOH
 "Last-Translator: FULL NAME <address@hidden>\\n"
 "Language-Team: LANGUAGE <address@hidden>\\n"
 "MIME-Version: 1.0\\n"
@@ -109,11 +130,17 @@
 EOH
 ;
 
-foreach my $key (keys %messages) {
-  print "#:";
-  foreach my $line (@{$messages{$key}}) {
-    print " $line";
+foreach my $occurence (@revmessages) {
+  my $key = $occurence->[2];
+  if (defined $messages{$key}) {
+    print "#:";
+    foreach my $line (@{$messages{$key}}) {
+      print " $line";
+    }
+    print "\nmsgid $key",
+      "msgstr \"\"\n\n";
+
+    # be sure we don't output the same message twice
+    delete $messages{$key};
   }
-  print "\nmsgid $key",
-    "msgstr \"\"\n\n";
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]