--- /usr/bin/intltool-extract	2007-03-21 13:36:18.000000000 -0400
+++ intltool-extract	2007-07-08 11:16:28.000000000 -0400
@@ -47,6 +47,7 @@
 my $UPDATE_ARG  = "0";
 my $QUIET_ARG   = "0";
 my $SRCDIR_ARG	= ".";
+my $NOMSGCTXT_ARG = "0";
 
 my $FILE;
 my $OUTFILE;
@@ -57,6 +58,7 @@
 my %loc = ();
 my %count = ();
 my %comments = ();
+my %contexts = ();
 my $strcount = 0;
 
 my $XMLCOMMENT = "";
@@ -76,6 +78,7 @@
             "update"     => \$UPDATE_ARG,
 	    "quiet|q"    => \$QUIET_ARG,
 	    "srcdir=s"	 => \$SRCDIR_ARG,
+	    "nomsgctxt"  => \$NOMSGCTXT_ARG,            
             ) or &error;
 
 &split_on_argument;
@@ -161,7 +164,8 @@
       --type=TYPE   Specify the file type of FILENAME. Currently supports:
                     "gettext/glade", "gettext/ini", "gettext/keys"
                     "gettext/rfc822deb", "gettext/schemas",
-                    "gettext/scheme", "gettext/xml", "gettext/quoted"
+                    "gettext/scheme", "gettext/xml", "gettext/quoted",
+                    "gettext/gtkbuilder"
   -l, --local       Writes output into current working directory
                     (conflicts with --update)
       --update      Writes output into the same directory the source file 
@@ -218,6 +222,7 @@
     &type_schemas  if $gettext_type eq "schemas";
     &type_rfc822deb  if $gettext_type eq "rfc822deb";
     &type_quoted if $gettext_type eq "quoted";
+    &type_gtkbuilder if $gettext_type eq "gtkbuilder";
 }
 
 sub entity_decode_minimal
@@ -761,6 +766,25 @@
     }
 }
 
+
+
+sub type_gtkbuilder {
+    ### For translatable GtkBuilder XML files ###
+
+    while ($input =~ /<(property|atkproperty)\s+[^>]*translatable\s*=\s*"(?i:yes|y|1|true|t)"(?:\s+[^>]*comments\s*=\s*"([^"]*)")?(?:\s+[^>]*context\s*="([^"]*)")?[^>]*>([^<]+)<\/\1>/sg) {
+	$messages{entity_decode($4)} = []; 
+        if (defined($2)) {
+	   $comments{entity_decode($4)} = entity_decode($2);
+        }
+        if (defined($3)) {
+	   $contexts{entity_decode($4)} = entity_decode($3);
+        }
+    }
+    while ($input =~ /<atkaction\s+action_name="([^>]*)"\s+description="([^>]+)"\/>/sg) {
+        $messages{entity_decode_minimal($2)} = [];
+    }
+}
+
 sub type_scheme {
     my ($line, $i, $state, $str, $trcomment, $char);
     for $line (split(/\n/, $input)) {
@@ -838,7 +862,21 @@
 	{
             if ($n == 0)
             {
- 		print OUT "char *s = N_(\""; 
+                if (defined $contexts{$message})
+                {
+		     if ($NOMSGCTXT_ARG)
+                     {
+			  print OUT "gettext (\"", $contexts{$message}, "|"; 
+                     }
+                     else
+                     {
+ 		          print OUT "pgettext (\"", $contexts{$message}, "\", \""; 
+                     }
+                }
+                else
+                {
+ 		     print OUT "gettext (\""; 
+                }
             }
             else
             {  
