Panu Matilainen 4b92b8
diff --git a/lib/tagexts.c b/lib/tagexts.c
Panu Matilainen 4b92b8
index 501d8ac..cf71639 100644
Panu Matilainen 4b92b8
--- a/lib/tagexts.c
Panu Matilainen 4b92b8
+++ b/lib/tagexts.c
Panu Matilainen 4b92b8
@@ -460,12 +460,6 @@ static int filerequireTag(Header h, rpmtd td)
Panu Matilainen 4b92b8
 }
Panu Matilainen 4b92b8
 
Panu Matilainen 4b92b8
 /* I18N look aside diversions */
Panu Matilainen 4b92b8
-
Panu Matilainen 4b92b8
-#if defined(ENABLE_NLS)
Panu Matilainen 4b92b8
-extern int _nl_msg_cat_cntr;	/* XXX GNU gettext voodoo */
Panu Matilainen 4b92b8
-#endif
Panu Matilainen 4b92b8
-static const char * const language = "LANGUAGE";
Panu Matilainen 4b92b8
-
Panu Matilainen 4b92b8
 static const char * const _macro_i18ndomains = "%{?_i18ndomains}";
Panu Matilainen 4b92b8
 
Panu Matilainen 4b92b8
 /**
Panu Matilainen 4b92b8
@@ -477,63 +471,27 @@ static const char * const _macro_i18ndomains = "%{?_i18ndomains}";
Panu Matilainen 4b92b8
  */
Panu Matilainen 4b92b8
 static int i18nTag(Header h, rpmTag tag, rpmtd td)
Panu Matilainen 4b92b8
 {
Panu Matilainen 4b92b8
-    char * dstring = rpmExpand(_macro_i18ndomains, NULL);
Panu Matilainen 4b92b8
-    int rc;
Panu Matilainen 4b92b8
+    int rc = headerGet(h, tag, td, HEADERGET_ALLOC);
Panu Matilainen 4b92b8
+    if (rc) {
Panu Matilainen 4b92b8
+    	char *de, *dstring = rpmExpand(_macro_i18ndomains, NULL);
Panu Matilainen 4b92b8
+	const char *domain;
Panu Matilainen 4b92b8
 
Panu Matilainen 4b92b8
-    td->type = RPM_STRING_TYPE;
Panu Matilainen 4b92b8
-    td->data = NULL;
Panu Matilainen 4b92b8
-    td->count = 0;
Panu Matilainen 4b92b8
-
Panu Matilainen 4b92b8
-    if (dstring && *dstring) {
Panu Matilainen 4b92b8
-	char *domain, *de;
Panu Matilainen 4b92b8
-	const char * langval;
Panu Matilainen 4b92b8
-	char * msgkey;
Panu Matilainen 4b92b8
-	const char * msgid;
Panu Matilainen 4b92b8
-	const char * n;
Panu Matilainen 4b92b8
-	int xx;
Panu Matilainen 4b92b8
-
Panu Matilainen 4b92b8
-	xx = headerNVR(h, &n, NULL, NULL);
Panu Matilainen 4b92b8
-	rasprintf(&msgkey, "%s(%s)", n, rpmTagGetName(tag));
Panu Matilainen 4b92b8
-
Panu Matilainen 4b92b8
-	/* change to en_US for msgkey -> msgid resolution */
Panu Matilainen 4b92b8
-	langval = getenv(language);
Panu Matilainen 4b92b8
-	(void) setenv(language, "en_US", 1);
Panu Matilainen 4b92b8
-#if defined(ENABLE_NLS)
Panu Matilainen 4b92b8
-        ++_nl_msg_cat_cntr;
Panu Matilainen 4b92b8
-#endif
Panu Matilainen 4b92b8
-
Panu Matilainen 4b92b8
-	msgid = NULL;
Panu Matilainen 4b92b8
 	for (domain = dstring; domain != NULL; domain = de) {
Panu Matilainen 4b92b8
+	    const char *msgid = td->data;
Panu Matilainen 4b92b8
+	    const char *msg = NULL;
Panu Matilainen 4b92b8
+
Panu Matilainen 4b92b8
 	    de = strchr(domain, ':');
Panu Matilainen 4b92b8
 	    if (de) *de++ = '\0';
Panu Matilainen 4b92b8
-	    msgid = dgettext(domain, msgkey);
Panu Matilainen 4b92b8
-	    if (msgid != msgkey) break;
Panu Matilainen 4b92b8
-	}
Panu Matilainen 4b92b8
-
Panu Matilainen 4b92b8
-	/* restore previous environment for msgid -> msgstr resolution */
Panu Matilainen 4b92b8
-	if (langval)
Panu Matilainen 4b92b8
-	    (void) setenv(language, langval, 1);
Panu Matilainen 4b92b8
-	else
Panu Matilainen 4b92b8
-	    unsetenv(language);
Panu Matilainen 4b92b8
-#if defined(ENABLE_NLS)
Panu Matilainen 4b92b8
-        ++_nl_msg_cat_cntr;
Panu Matilainen 4b92b8
-#endif
Panu Matilainen 4b92b8
-
Panu Matilainen 4b92b8
-	if (domain && msgid) {
Panu Matilainen 4b92b8
-	    td->data = dgettext(domain, msgid);
Panu Matilainen 4b92b8
-	    td->data = xstrdup(td->data); /* XXX xstrdup has side effects. */
Panu Matilainen 4b92b8
-	    td->count = 1;
Panu Matilainen 4b92b8
-	    td->flags = RPMTD_ALLOCED;
Panu Matilainen 4b92b8
+	    msg = dgettext(domain, td->data);
Panu Matilainen 4b92b8
+	    if (msg != msgid) {
Panu Matilainen 4b92b8
+		free(td->data);
Panu Matilainen 4b92b8
+		td->data = xstrdup(msg);
Panu Matilainen 4b92b8
+		break;
Panu Matilainen 4b92b8
+	    }
Panu Matilainen 4b92b8
 	}
Panu Matilainen 4b92b8
-	dstring = _free(dstring);
Panu Matilainen 4b92b8
-	free(msgkey);
Panu Matilainen 4b92b8
-	if (td->data)
Panu Matilainen 4b92b8
-	    return 1;
Panu Matilainen 4b92b8
+	free(dstring);
Panu Matilainen 4b92b8
     }
Panu Matilainen 4b92b8
-
Panu Matilainen 4b92b8
-    dstring = _free(dstring);
Panu Matilainen 4b92b8
-
Panu Matilainen 4b92b8
-    rc = headerGet(h, tag, td, HEADERGET_DEFAULT);
Panu Matilainen 4b92b8
+	
Panu Matilainen 4b92b8
     return rc;
Panu Matilainen 4b92b8
 }
Panu Matilainen 4b92b8