richardphibel / rpms / rpm

Forked from rpms/rpm 2 years ago
Clone
043c42
diff --git a/lib/tagexts.c b/lib/tagexts.c
043c42
index f72ff60..2c0b179 100644
043c42
--- a/lib/tagexts.c
043c42
+++ b/lib/tagexts.c
043c42
@@ -535,15 +535,6 @@ static int filerequireTag(Header h, rpmtd td, headerGetFlags hgflags)
043c42
     return filedepTag(h, RPMTAG_REQUIRENAME, td, hgflags);
043c42
 }
043c42
 
043c42
-/* I18N look aside diversions */
043c42
-
043c42
-#if defined(ENABLE_NLS)
043c42
-extern int _nl_msg_cat_cntr;	/* XXX GNU gettext voodoo */
043c42
-#endif
043c42
-static const char * const language = "LANGUAGE";
043c42
-
043c42
-static const char * const _macro_i18ndomains = "%{?_i18ndomains}";
043c42
-
043c42
 /**
043c42
  * Retrieve i18n text.
043c42
  * @param h		header
043c42
@@ -554,59 +545,30 @@ static const char * const _macro_i18ndomains = "%{?_i18ndomains}";
043c42
  */
043c42
 static int i18nTag(Header h, rpmTag tag, rpmtd td, headerGetFlags hgflags)
043c42
 {
043c42
-    int rc;
043c42
+    int rc = headerGet(h, tag, td, HEADERGET_ALLOC);
043c42
 #if defined(ENABLE_NLS)
043c42
-    char * dstring = rpmExpand(_macro_i18ndomains, NULL);
043c42
-
043c42
-    td->type = RPM_STRING_TYPE;
043c42
-    td->data = NULL;
043c42
-    td->count = 0;
043c42
-
043c42
-    if (dstring && *dstring) {
043c42
-	char *domain, *de;
043c42
-	const char * langval;
043c42
-	char * msgkey;
043c42
-	const char * msgid;
043c42
+    if (rc) {
043c42
+	static const char * const _macro_i18ndomains = "%{?_i18ndomains}";
043c42
+	char *de, *dstring = rpmExpand(_macro_i18ndomains, NULL);
043c42
+	const char *domain;
043c42
 
043c42
-	rasprintf(&msgkey, "%s(%s)", headerGetString(h, RPMTAG_NAME), 
043c42
-		  rpmTagGetName(tag));
043c42
-
043c42
-	/* change to en_US for msgkey -> msgid resolution */
043c42
-	langval = getenv(language);
043c42
-	(void) setenv(language, "en_US", 1);
043c42
-        ++_nl_msg_cat_cntr;
043c42
-
043c42
-	msgid = NULL;
043c42
 	for (domain = dstring; domain != NULL; domain = de) {
043c42
+	    const char *msgid = td->data;
043c42
+	    const char *msg = NULL;
043c42
+
043c42
 	    de = strchr(domain, ':');
043c42
 	    if (de) *de++ = '\0';
043c42
-	    msgid = dgettext(domain, msgkey);
043c42
-	    if (msgid != msgkey) break;
043c42
-	}
043c42
-
043c42
-	/* restore previous environment for msgid -> msgstr resolution */
043c42
-	if (langval)
043c42
-	    (void) setenv(language, langval, 1);
043c42
-	else
043c42
-	    unsetenv(language);
043c42
-        ++_nl_msg_cat_cntr;
043c42
-
043c42
-	if (domain && msgid) {
043c42
-	    td->data = dgettext(domain, msgid);
043c42
-	    td->data = xstrdup(td->data); /* XXX xstrdup has side effects. */
043c42
-	    td->count = 1;
043c42
-	    td->flags = RPMTD_ALLOCED;
043c42
+	    msg = dgettext(domain, td->data);
043c42
+	    if (msg != msgid) {
043c42
+		free(td->data);
043c42
+		td->data = xstrdup(msg);
043c42
+		break;
043c42
+	    }
043c42
 	}
043c42
-	dstring = _free(dstring);
043c42
-	free(msgkey);
043c42
-	if (td->data)
043c42
-	    return 1;
043c42
+	free(dstring);
043c42
     }
043c42
-
043c42
-    free(dstring);
043c42
 #endif
043c42
 
043c42
-    rc = headerGet(h, tag, td, HEADERGET_ALLOC);
043c42
     return rc;
043c42
 }
043c42