diff --git a/gettext-tools/src/x-glade.c b/gettext-tools/src/x-glade.c
index 11f8397..d052aee 100644
--- a/gettext-tools/src/x-glade.c
+++ b/gettext-tools/src/x-glade.c
@@ -386,6 +386,7 @@ struct element_state
 {
   bool extract_string;
   char *extracted_comment;
+  const char *extracted_context;
   int lineno;
   char *buffer;
   size_t bufmax;
@@ -411,6 +412,26 @@ ensure_stack_size (size_t size)
 
 static size_t stack_depth;
 
+static const char *
+extract_context (const char **attributes)
+{
+  bool found_context = false;
+  const char ** attp = attributes;
+  const char * context = NULL;
+
+  while (!found_context && (*attp != NULL))
+    {
+      if (strcmp (attp[0], "context") == 0)
+	{
+	  found_context = true;
+	  context = attp[1];
+	}
+      attp += 2;
+    }
+
+  return context;
+}
+
 /* Callback called when <element> is seen.  */
 static void
 start_element_handler (void *userData, const char *name,
@@ -429,6 +450,7 @@ start_element_handler (void *userData, const char *name,
   p = &stack[stack_depth];
   p->extract_string = extract_all;
   p->extracted_comment = NULL;
+  p->extracted_context = extract_context (attributes);
   /* In Glade 1, a few specific elements are translatable.  */
   if (!p->extract_string)
     p->extract_string =
@@ -470,11 +492,14 @@ start_element_handler (void *userData, const char *name,
               if (strcmp (attp[1], "") != 0)
                 {
                   lex_pos_ty pos;
+                  char * context = (p->extracted_context != NULL)
+                                    ? xstrdup (p->extracted_context)
+                                    : NULL;
 
                   pos.file_name = logical_file_name;
                   pos.line_number = XML_GetCurrentLineNumber (parser);
 
-                  remember_a_message (mlp, NULL, xstrdup (attp[1]),
+                  remember_a_message (mlp, context, xstrdup (attp[1]),
                                       null_context, &pos,
                                       NULL, savable_comment);
                 }
@@ -504,6 +529,9 @@ end_element_handler (void *userData, const char *name)
       if (p->buflen > 0)
         {
           lex_pos_ty pos;
+          char * context = (p->extracted_context != NULL)
+                            ? xstrdup (p->extracted_context)
+                            : NULL;
 
           if (p->buflen == p->bufmax)
             p->buffer = (char *) xrealloc (p->buffer, p->buflen + 1);
@@ -512,8 +540,8 @@ end_element_handler (void *userData, const char *name)
           pos.file_name = logical_file_name;
           pos.line_number = p->lineno;
 
-          remember_a_message (mlp, NULL, p->buffer, null_context, &pos,
-                              p->extracted_comment, savable_comment);
+          remember_a_message (mlp, context, p->buffer, null_context, &pos,
+			      p->extracted_comment, savable_comment);
           p->buffer = NULL;
         }
     }
