summaryrefslogtreecommitdiff
path: root/doc-i18n-tool
diff options
context:
space:
mode:
authorveillard <>2002-02-16 22:01:12 +0000
committerveillard <>2002-02-16 22:01:12 +0000
commit79238fc49519054ca53758ba231785fdaf88b21a (patch)
tree6beee3916692f17463ad73e6db55d18a96b3826f /doc-i18n-tool
parent54e3e2a91b0fb603ac1f40f43d2d90cd852e1053 (diff)
downloadintltool-79238fc49519054ca53758ba231785fdaf88b21a.tar.gz
* doc-i18n-tool/doc-i18n-tool.c: added the capacity to ignore
presentation element (not cascading though), currently only "accel" is part of the list, edit and add it to the presentation element list. Asked by jdub. Daniel
Diffstat (limited to 'doc-i18n-tool')
-rw-r--r--doc-i18n-tool/doc-i18n-tool.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/doc-i18n-tool/doc-i18n-tool.c b/doc-i18n-tool/doc-i18n-tool.c
index 7296faa..64cac50 100644
--- a/doc-i18n-tool/doc-i18n-tool.c
+++ b/doc-i18n-tool/doc-i18n-tool.c
@@ -52,6 +52,17 @@ struct poptOption options [] =
{ NULL, '\0', 0, NULL, 0}
};
+/*
+ * Null terminated list of elements which should be considered
+ * presentational and should not break strings.
+ *
+ * Add elements names as needed.
+ */
+const char *presentation_elements[] = {
+ "accel",
+ NULL
+};
+
xmlChar *
processString (const xmlChar *value,
@@ -126,6 +137,51 @@ processNode (xmlNodePtr node,
node->content = res;
}
}
+ else if (node->type == XML_ELEMENT_NODE)
+ {
+ int pres;
+ xmlNodePtr children = node->children;
+ const xmlChar *name;
+ const char **tst;
+
+ if (children == NULL)
+ return;
+
+ pres = 1;
+ /* check to see if all children are only text or presentation elements */
+ while ((children != NULL) && (pres != 0)) {
+ if (children->type == XML_ELEMENT_NODE) {
+ name = children->name;
+ tst = presentation_elements;
+ while (*tst != NULL) {
+ if (!xmlStrcmp((const xmlChar *)*tst, name))
+ break;
+ tst++;
+ }
+ if (*tst == NULL) {
+ pres = 0;
+ break;
+ }
+ }
+ children = children->next;
+ }
+ if (pres == 1) {
+ xmlChar *content;
+
+ /*
+ * get the value, scrap the node list, replace with
+ * the modified text content. Let the tree walking
+ * process the text node at the next step.
+ */
+ content = xmlNodeGetContent(node);
+ children = node->children;
+ node->last = node->children = NULL;
+ xmlFreeNodeList(children);
+ children = xmlNewDocText(node->doc, content);
+ xmlAddChild(node, children);
+ xmlFree(content);
+ }
+ }
}
static void