summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanilo Segan <danilo@canonical.com>2011-10-08 16:34:15 +0200
committerDanilo Segan <danilo@canonical.com>2011-10-08 16:34:15 +0200
commitfa63e925e54fe6be717e83dbca23981d9c182148 (patch)
treee48821f984b76c6cb3fe380a1728dd893363bc7d
parent89f88216270e6eef94efe02f26b712570503bfc8 (diff)
parentb9f7f501f21f61190e5bda78d2d1534c1be9ed46 (diff)
downloadintltool-fa63e925e54fe6be717e83dbca23981d9c182148.tar.gz
Keep the order of messages on extraction with intltool-extract. Fixes #520986.
-rw-r--r--intltool-extract.in40
-rw-r--r--tests/results/context.xml.in.h2
-rw-r--r--tests/results/extract-comments.xml.h18
-rw-r--r--tests/results/extract-gtkbuilder.ui.h2
-rw-r--r--tests/results/extract12.xml.in.h2
-rw-r--r--tests/results/extract13.desktop.in.h2
-rw-r--r--tests/results/extract14.xml.in.h6
-rw-r--r--tests/results/extract7.xml.h10
-rw-r--r--tests/results/extract8.glade.h16
-rw-r--r--tests/results/extract9.xml.in.h4
-rw-r--r--tests/results/iso88591text.xml.in.h6
-rw-r--r--tests/results/space-preserve.xml.in.h4
-rw-r--r--tests/results/test-quoted.dtd.h4
-rw-r--r--tests/results/test.schemas.in.h6
-rw-r--r--tests/results/test.scm.h16
-rw-r--r--tests/results/unicodetext.xml.in.h6
16 files changed, 76 insertions, 68 deletions
diff --git a/intltool-extract.in b/intltool-extract.in
index 6cdcd52..15cd622 100644
--- a/intltool-extract.in
+++ b/intltool-extract.in
@@ -55,6 +55,7 @@ my $OUTFILE;
my $gettext_type = "";
my $input;
my %messages = ();
+my @messages_sorted = ();
my %loc = ();
my %count = ();
my %comments = ();
@@ -77,7 +78,7 @@ GetOptions (
"update" => \$UPDATE_ARG,
"quiet|q" => \$QUIET_ARG,
"srcdir=s" => \$SRCDIR_ARG,
- "nomsgctxt" => \$NOMSGCTXT_ARG,
+ "nomsgctxt" => \$NOMSGCTXT_ARG,
) or &error;
&split_on_argument;
@@ -265,20 +266,27 @@ sub escape
return join "", map &escape_char, split //, $string;
}
+sub add_message
+{
+ my ($string) = @_;
+ push @messages_sorted, $string if !defined $messages{$string};
+ $messages{$string} = [];
+}
+
sub type_ini {
### For generic translatable desktop files ###
while ($input =~ /^(#(.+)\n)?^_.*=(.*)$/mg) {
if (defined($2)) {
$comments{$3} = $2;
}
- $messages{$3} = [];
+ add_message($3);
}
}
sub type_keys {
### For generic translatable mime/keys files ###
while ($input =~ /^\s*_\w+=(.*)$/mg) {
- $messages{$1} = [];
+ add_message($1);
}
}
@@ -340,7 +348,7 @@ sub getAttributeString
## differences from intltool-merge.in.in
if ($key =~ /^_/) {
$comments{entity_decode($string)} = $XMLCOMMENT if $XMLCOMMENT;
- $messages{entity_decode($string)} = [];
+ add_message(entity_decode($string));
$$translate = 2;
}
## differences end here from intltool-merge.in.in
@@ -457,7 +465,7 @@ sub traverse
if ($lookup && $translate != 2) {
$comments{$lookup} = $XMLCOMMENT if $XMLCOMMENT;
- $messages{$lookup} = [];
+ add_message($lookup);
} elsif ($translate == 2) {
translate_subnodes($fh, \@all, $language, 1, $spacepreserve);
}
@@ -646,7 +654,7 @@ sub type_schemas {
my $currentcomment = shift @eachcomment;
next if !$_;
s/\s+/ /g;
- $messages{entity_decode_minimal($_)} = [];
+ add_message(entity_decode_minimal($_));
$comments{entity_decode_minimal($_)} = $currentcomment if (defined($currentcomment));
}
}
@@ -669,7 +677,7 @@ sub type_rfc822deb {
for my $str (@str_list)
{
$strcount++;
- $messages{$str} = [];
+ add_message($str);
$loc{$str} = $lineno;
$count{$str} = $strcount;
my $usercomment = '';
@@ -737,7 +745,7 @@ sub type_quoted {
my $before = $`;
$message =~ s/\\\"/\"/g;
$before =~ s/[^\n]//g;
- $messages{$message} = [];
+ add_message($message);
$loc{$message} = length ($before) + 2;
}
}
@@ -749,7 +757,7 @@ sub type_quotedxml {
$message =~ s/\\\"/\"/g;
$message = entity_decode($message);
$before =~ s/[^\n]//g;
- $messages{$message} = [];
+ add_message($message);
$loc{$message} = length ($before) + 2;
}
}
@@ -763,12 +771,12 @@ sub type_glade {
# Glade sometimes uses tags that normally mark translatable things for
# little bits of non-translatable content. We work around this by not
# translating strings that only includes something like label4 or window1.
- $messages{entity_decode($2)} = [] unless $2 =~ /^(window|label|dialog)[0-9]+$/;
+ add_message(entity_decode($2)) unless $2 =~ /^(window|label|dialog)[0-9]+$/;
}
while ($input =~ /<items>(..[^<]*)<\/items>/sg) {
for my $item (split (/\n/, $1)) {
- $messages{entity_decode($item)} = [];
+ add_message(entity_decode($item));
}
}
@@ -779,14 +787,14 @@ sub type_glade {
if (defined($2)) {
$message = entity_decode($2) . "\004" . $message;
}
- $messages{$message} = [];
+ add_message($message);
if (defined($3)) {
$comments{$message} = entity_decode($3) ;
}
}
}
while ($input =~ /<atkaction\s+action_name="([^>]*)"\s+description="([^>]+)"\/>/sg) {
- $messages{entity_decode_minimal($2)} = [];
+ add_message(entity_decode_minimal($2));
}
}
@@ -799,7 +807,7 @@ sub type_scheme {
if (substr($line,$i,1) eq "\"") {
if ($state == 2) {
$comments{$str} = $trcomment if ($trcomment);
- $messages{$str} = [];
+ add_message($str);
$str = '';
$state = 0; $trcomment = "";
} elsif ($state == 1) {
@@ -914,7 +922,7 @@ sub type_tlk {
if (defined $message) {
use Encode;
Encode::from_to ($message, "iso-8859-1", "UTF-8");
- $messages{$message} = [];
+ add_message($message);
if ($message =~ /^Bad Strref$/ ) {
$comments{$message} = "DO NOT Translate this Entry.";
$comments{$message} .= "\nTLK:position=$count";
@@ -941,7 +949,7 @@ sub msg_write {
}
else
{
- @msgids = sort keys %messages;
+ @msgids = @messages_sorted;
}
for my $message (@msgids)
{
diff --git a/tests/results/context.xml.in.h b/tests/results/context.xml.in.h
index 04ec538..161a65b 100644
--- a/tests/results/context.xml.in.h
+++ b/tests/results/context.xml.in.h
@@ -1,7 +1,7 @@
+char *s = N_("Foo");
/* This is the comment on the first Bar */
char *s = C_("1", "Bar");
/* This is the comment on the second Bar */
char *s = C_("2", "Bar");
/* This is the comment on Baz */
char *s = N_("Baz");
-char *s = N_("Foo");
diff --git a/tests/results/extract-comments.xml.h b/tests/results/extract-comments.xml.h
index 451aa79..d7e1222 100644
--- a/tests/results/extract-comments.xml.h
+++ b/tests/results/extract-comments.xml.h
@@ -1,19 +1,19 @@
-/* This comment is not ignored even if it contains > (greater than)
-sign in it, and the following string shows up as well */
-char *s = N_("Dum-dee-dum");
-/* If comment doesn't end on the previous line, it should be handled
- correctly */
-char *s = N_("Final thing to translate");
/* This comment is not ignored */
char *s = N_("First thing to translate");
/* This is multi line comment for the following string;
second line of multi-line comment */
char *s = N_("Something to translate");
+/* If comment doesn't end on the previous line, it should be handled
+ correctly */
+char *s = N_("Final thing to translate");
char *s = N_("This doesn't have a comment for translators");
-/* Comment for *both* attributes and content */
-char *s = N_("attribute value");
+/* This comment is not ignored even if it contains > (greater than)
+sign in it, and the following string shows up as well */
+char *s = N_("Dum-dee-dum");
+char *s = N_("attribute without comment");
/* This comment will appear if attributes can be commented about */
char *s = N_("attribute with comment");
-char *s = N_("attribute without comment");
+/* Comment for *both* attributes and content */
+char *s = N_("attribute value");
/* Comment for *both* attributes and content */
char *s = N_("even more content");
diff --git a/tests/results/extract-gtkbuilder.ui.h b/tests/results/extract-gtkbuilder.ui.h
index acdaf36..da417c8 100644
--- a/tests/results/extract-gtkbuilder.ui.h
+++ b/tests/results/extract-gtkbuilder.ui.h
@@ -1,3 +1,3 @@
-char *s = C_("developer", "help");
char *s = N_("help");
char *s = C_("user", "help");
+char *s = C_("developer", "help");
diff --git a/tests/results/extract12.xml.in.h b/tests/results/extract12.xml.in.h
index 65bec24..4277e62 100644
--- a/tests/results/extract12.xml.in.h
+++ b/tests/results/extract12.xml.in.h
@@ -1,3 +1,3 @@
-char *s = N_("Normal name");
char *s = N_("Other attribute");
+char *s = N_("Normal name");
char *s = N_("Other name");
diff --git a/tests/results/extract13.desktop.in.h b/tests/results/extract13.desktop.in.h
index fe380d0..e9df7b9 100644
--- a/tests/results/extract13.desktop.in.h
+++ b/tests/results/extract13.desktop.in.h
@@ -1,5 +1,5 @@
-char *s = N_("Blue");
/* 2. This comment should be extracted. */
char *s = N_("Find Files...");
/* 4. This comment also should be extracted. */
char *s = N_("Locate documents and folders on this computer by name or content");
+char *s = N_("Blue");
diff --git a/tests/results/extract14.xml.in.h b/tests/results/extract14.xml.in.h
index 4f378e6..a021664 100644
--- a/tests/results/extract14.xml.in.h
+++ b/tests/results/extract14.xml.in.h
@@ -1,4 +1,4 @@
-char *s = N_("The &amp;gt; entity produces the &gt; character");
-char *s = N_("The &amp;lt; entity produces the &lt; character");
-char *s = N_("The &gt; entity produces the > character");
char *s = N_("The &lt; entity produces the < character");
+char *s = N_("The &gt; entity produces the > character");
+char *s = N_("The &amp;lt; entity produces the &lt; character");
+char *s = N_("The &amp;gt; entity produces the &gt; character");
diff --git a/tests/results/extract7.xml.h b/tests/results/extract7.xml.h
index fbab6e4..13a1f3e 100644
--- a/tests/results/extract7.xml.h
+++ b/tests/results/extract7.xml.h
@@ -1,9 +1,9 @@
char *s = N_("<big>Welcome to The GIMP !</big>");
-char *s = N_("Most plug-ins work on the current layer of the current image. In some cases, you will have to merge all layers (Layers-&gt;Flatten Image) if you want the plug-in to work on the whole image.");
char *s = N_("Nearly all image operations are performed by right-clicking on the image. And don't worry, you can undo most mistakes...");
-char *s = N_("Not all effects can be applied to all kinds of images. This is indicated by a grayed-out menu-entry. You may need to change the image mode to RGB (Image-&gt;Mode-&gt;RGB), add an alpha-channel (Layers-&gt;Add Alpha Channel) or flatten it (Layers-&gt;Flatten Image).");
-char *s = N_("The GIMP uses layers to let you organize your image. Think of them as a stack of slides or filters, such that looking through them you see a composite of their contents.");
-char *s = N_("The layer named &quot;Background&quot; it special because it lacks transparency. This prevents you from adding a layer mask or moving the layer up in the stack. You may add transparency to it by right-clicking in the &quot;Layers, Channels and Paths&quot; dialog and selecting &quot;Add Alpha Channel&quot;.");
-char *s = N_("When you save an image to work on it again later, try using XCF, the GIMP's native file format (use the file extension <tt>.xcf</tt>). This preserves the layers and every aspect of your work-in-progress. Once a project is completed, you can save it as JPEG, PNG, GIF, ...");
char *s = N_("You can get context-sensitive help for most of the GIMP's features by pressing the F1 key at any time. This also works inside the menus.");
+char *s = N_("The GIMP uses layers to let you organize your image. Think of them as a stack of slides or filters, such that looking through them you see a composite of their contents.");
char *s = N_("You can perform many layer operations by right-clicking on the text label of a layer in the &quot;Layers, Channels and Paths&quot; dialog.");
+char *s = N_("When you save an image to work on it again later, try using XCF, the GIMP's native file format (use the file extension <tt>.xcf</tt>). This preserves the layers and every aspect of your work-in-progress. Once a project is completed, you can save it as JPEG, PNG, GIF, ...");
+char *s = N_("The layer named &quot;Background&quot; it special because it lacks transparency. This prevents you from adding a layer mask or moving the layer up in the stack. You may add transparency to it by right-clicking in the &quot;Layers, Channels and Paths&quot; dialog and selecting &quot;Add Alpha Channel&quot;.");
+char *s = N_("Most plug-ins work on the current layer of the current image. In some cases, you will have to merge all layers (Layers-&gt;Flatten Image) if you want the plug-in to work on the whole image.");
+char *s = N_("Not all effects can be applied to all kinds of images. This is indicated by a grayed-out menu-entry. You may need to change the image mode to RGB (Image-&gt;Mode-&gt;RGB), add an alpha-channel (Layers-&gt;Add Alpha Channel) or flatten it (Layers-&gt;Flatten Image).");
diff --git a/tests/results/extract8.glade.h b/tests/results/extract8.glade.h
index 9eddf85..fd82e2a 100644
--- a/tests/results/extract8.glade.h
+++ b/tests/results/extract8.glade.h
@@ -1,13 +1,13 @@
+char *s = N_("Testing");
/* Comment on <property> tag */
char *s = N_("A label");
-char *s = N_("Cancel (and exit) the test.");
-char *s = N_("Click the button below");
-char *s = N_("Testing");
-char *s = N_("Testing2");
-char *s = N_("This action\n"
- "does nothing interesting.");
-char *s = N_("This button\n"
- "dares you to invoke this action.");
/* Multiline comments
should be supported as well */
char *s = N_("_Push me");
+char *s = N_("Testing2");
+char *s = N_("Click the button below");
+char *s = N_("This button\n"
+ "dares you to invoke this action.");
+char *s = N_("This action\n"
+ "does nothing interesting.");
+char *s = N_("Cancel (and exit) the test.");
diff --git a/tests/results/extract9.xml.in.h b/tests/results/extract9.xml.in.h
index a5e9572..ee8ac42 100644
--- a/tests/results/extract9.xml.in.h
+++ b/tests/results/extract9.xml.in.h
@@ -1,3 +1,5 @@
+char *s = N_("Welcome to The GIMP !");
+char *s = N_("Nearly all image operations are performed by right-clicking on the image. And don't worry, you can undo most mistakes.");
char *s = N_("\n"
"\n"
"\n"
@@ -6,5 +8,3 @@ char *s = N_("\n"
"\n"
"\n"
" ");
-char *s = N_("Nearly all image operations are performed by right-clicking on the image. And don't worry, you can undo most mistakes.");
-char *s = N_("Welcome to The GIMP !");
diff --git a/tests/results/iso88591text.xml.in.h b/tests/results/iso88591text.xml.in.h
index 685fc66..28005a7 100644
--- a/tests/results/iso88591text.xml.in.h
+++ b/tests/results/iso88591text.xml.in.h
@@ -1,5 +1,5 @@
-/* Translators: This is in Chambéry in France. */
-char *s = N_("Aix-les-Bains");
+char *s = N_("Europe");
/* Translators: This is in France. */
char *s = N_("Chambéry");
-char *s = N_("Europe");
+/* Translators: This is in Chambéry in France. */
+char *s = N_("Aix-les-Bains");
diff --git a/tests/results/space-preserve.xml.in.h b/tests/results/space-preserve.xml.in.h
index 606afa2..d489d39 100644
--- a/tests/results/space-preserve.xml.in.h
+++ b/tests/results/space-preserve.xml.in.h
@@ -1,8 +1,8 @@
-char *s = N_("And this message should take no more than one single row, no matter the spacing in the source file.");
char *s = N_("Insufficient disk space for upgrade.");
-char *s = N_("This is not an error.");
char *s = N_("Upgrading your data and settings will require up to {0} of disk\n"
"space, but you only have {1} available.\n"
"\n"
"You will need to make more space available in your home directory before you can\n"
"continue.");
+char *s = N_("This is not an error.");
+char *s = N_("And this message should take no more than one single row, no matter the spacing in the source file.");
diff --git a/tests/results/test-quoted.dtd.h b/tests/results/test-quoted.dtd.h
index 5289b02..e7e0476 100644
--- a/tests/results/test-quoted.dtd.h
+++ b/tests/results/test-quoted.dtd.h
@@ -1,8 +1,8 @@
# 1 "cases/test-quoted.dtd"
char *s = N_("Channel requires &quot;authentication&quot;");
-# 4 "cases/test-quoted.dtd"
-char *s = N_("Password\\a:");
# 2 "cases/test-quoted.dtd"
char *s = N_("Please enter the username and password given to you by this channel's publisher.");
# 3 "cases/test-quoted.dtd"
char *s = N_("Username\"foo\":");
+# 4 "cases/test-quoted.dtd"
+char *s = N_("Password\\a:");
diff --git a/tests/results/test.schemas.in.h b/tests/results/test.schemas.in.h
index 883db48..ee467e3 100644
--- a/tests/results/test.schemas.in.h
+++ b/tests/results/test.schemas.in.h
@@ -1,10 +1,10 @@
-char *s = N_("12");
/* default value for /schemas/apps/clock_applet/prefs/hour_format
The translation should only include the localized default
eg. 12 or 24 */
char *s = N_("24");
-char *s = N_("Display seconds in time");
char *s = N_("Hour format");
-char *s = N_("Puh long.");
char *s = N_("Sets the hour format, may be either 12 or 24");
+char *s = N_("Display seconds in time");
+char *s = N_("12");
char *s = N_("Something random..even has >");
+char *s = N_("Puh long.");
diff --git a/tests/results/test.scm.h b/tests/results/test.scm.h
index e75a4e2..e514380 100644
--- a/tests/results/test.scm.h
+++ b/tests/results/test.scm.h
@@ -1,11 +1,11 @@
-/* so "what? */
-char *s = N_("another \" string");
-char *s = N_("here");
-/* all well */
-char *s = N_("multiple");
-/* this is a fine comment for translators */
-char *s = N_("nice string; thanks");
/* silly comment */
char *s = N_("translatable string");
-char *s = N_("translation");
+/* this is a fine comment for translators */
+char *s = N_("nice string; thanks");
+/* all well */
+char *s = N_("multiple");
char *s = N_("translations; per line");
+char *s = N_("translation");
+/* so "what? */
+char *s = N_("another \" string");
+char *s = N_("here");
diff --git a/tests/results/unicodetext.xml.in.h b/tests/results/unicodetext.xml.in.h
index b4258f3..ad78437 100644
--- a/tests/results/unicodetext.xml.in.h
+++ b/tests/results/unicodetext.xml.in.h
@@ -1,5 +1,5 @@
-/* Translators: This is in Chambéry in France. */
-char *s = N_("Aix-les-Bains");
+char *s = N_("Europe");
/* Translators: This is in France. */
char *s = N_("Chambéry");
-char *s = N_("Europe");
+/* Translators: This is in Chambéry in France. */
+char *s = N_("Aix-les-Bains");