michal-grzedzicki / rpms / rpm

Forked from rpms/rpm 5 months ago
Clone
5860f5
diff --git a/lib/tagexts.c b/lib/tagexts.c
5860f5
index dc0e0fb..e0a5d1f 100644
5860f5
--- a/lib/tagexts.c
5860f5
+++ b/lib/tagexts.c
5860f5
@@ -478,59 +478,29 @@ static const char * const _macro_i18ndomains = "%{?_i18ndomains}";
5860f5
  */
5860f5
 static int i18nTag(Header h, rpmTag tag, rpmtd td, headerGetFlags hgflags)
5860f5
 {
5860f5
-    int rc;
5860f5
+    int rc = headerGet(h, tag, td, HEADERGET_ALLOC);
5860f5
 #if defined(ENABLE_NLS)
5860f5
-    char * dstring = rpmExpand(_macro_i18ndomains, NULL);
5860f5
-
5860f5
-    td->type = RPM_STRING_TYPE;
5860f5
-    td->data = NULL;
5860f5
-    td->count = 0;
5860f5
-
5860f5
-    if (dstring && *dstring) {
5860f5
-	char *domain, *de;
5860f5
-	const char * langval;
5860f5
-	char * msgkey;
5860f5
-	const char * msgid;
5860f5
-
5860f5
-	rasprintf(&msgkey, "%s(%s)", headerGetString(h, RPMTAG_NAME), 
5860f5
-		  rpmTagGetName(tag));
5860f5
-
5860f5
-	/* change to en_US for msgkey -> msgid resolution */
5860f5
-	langval = getenv(language);
5860f5
-	(void) setenv(language, "en_US", 1);
5860f5
-        ++_nl_msg_cat_cntr;
5860f5
+    if (rc) {
5860f5
+	char *de, *dstring = rpmExpand(_macro_i18ndomains, NULL);
5860f5
+	const char *domain;
5860f5
 
5860f5
-	msgid = NULL;
5860f5
 	for (domain = dstring; domain != NULL; domain = de) {
5860f5
+	    const char *msgid = td->data;
5860f5
+	    const char *msg = NULL;
5860f5
+
5860f5
 	    de = strchr(domain, ':');
5860f5
 	    if (de) *de++ = '\0';
5860f5
-	    msgid = dgettext(domain, msgkey);
5860f5
-	    if (msgid != msgkey) break;
5860f5
-	}
5860f5
-
5860f5
-	/* restore previous environment for msgid -> msgstr resolution */
5860f5
-	if (langval)
5860f5
-	    (void) setenv(language, langval, 1);
5860f5
-	else
5860f5
-	    unsetenv(language);
5860f5
-        ++_nl_msg_cat_cntr;
5860f5
-
5860f5
-	if (domain && msgid) {
5860f5
-	    td->data = dgettext(domain, msgid);
5860f5
-	    td->data = xstrdup(td->data); /* XXX xstrdup has side effects. */
5860f5
-	    td->count = 1;
5860f5
-	    td->flags = RPMTD_ALLOCED;
5860f5
+	    msg = dgettext(domain, td->data);
5860f5
+	    if (msg != msgid) {
5860f5
+		free(td->data);
5860f5
+		td->data = xstrdup(msg);
5860f5
+		break;
5860f5
+	    }
5860f5
 	}
5860f5
-	dstring = _free(dstring);
5860f5
-	free(msgkey);
5860f5
-	if (td->data)
5860f5
-	    return 1;
5860f5
+	free(dstring);
5860f5
     }
5860f5
-
5860f5
-    free(dstring);
5860f5
 #endif
5860f5
 
5860f5
-    rc = headerGet(h, tag, td, HEADERGET_ALLOC);
5860f5
     return rc;
5860f5
 }
5860f5