From d8c9a667e6af706cc7729e3d90b8f80b12c4f80e Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <wellnhofer@aevum.de>
Date: Tue, 27 May 2025 21:45:06 +0200
Subject: [PATCH] Fix extraction of namespaced attributes from langPointer

---
 itstool.in | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/itstool.in b/itstool.in
index 78887ca..c7729fd 100755
--- a/itstool.in
+++ b/itstool.in
@@ -677,8 +677,18 @@ class Document (object):
                     # language information. Technically, langPointer could be
                     # any XPath expression. But if it looks like an attribute
                     # accessor, just use the attribute name.
+                    # TODO: This should probably be skipped if langPointer
+                    # equals '@xml:lang' which is the default.
                     if lp[0] == '@':
-                        self._itst_lang_attr[node] = lp[1:]
+                        name = lp[1:]
+                        if ':' in name:
+                            prefix, lname = name.split(':', 2)
+                            nsuri = node.nsmap.get(prefix)
+                            if nsuri is None:
+                                name = lname
+                            else:
+                                name = '{' + nsuri + '}' + lname
+                        self._itst_lang_attr[node] = name
         elif rule.tag == '{' + NS_ITST + '}credits':
             sel = rule.get('appendTo')
             if sel is not None:
