From 823ad0f3b1e5ae4e79d90c04a297746f30db380d Mon Sep 17 00:00:00 2001 From: Bernardo Gonzalez Kriegel Date: Mon, 29 Apr 2013 13:07:11 -0300 Subject: [PATCH] Bug 6709 - marc21_field_006.xml and marc21_field_008.xml can't be translated This patch changes 1) structure and schema for xml files used in MARC21 006 and 008 value builders. 2) JavaScript functions used to show value builders. Xml processing is enabled in previous patch Any translatable string has been moved to an xml element, those strings that no need translation remains as xml attributes. NOTE_1: I do not include as translatable material types codes, because those values are restricted in schema definition. But this restriction can be removed. NOTE_2: Anyone with experience in XML/XSD please check the new schema definition. NOTE_3: Anyone with experience in the former and JavaScript please check xmlControlfield.js To test: 1) Apply the patch 2) Verify that 006 and 008 value builders show and work properly 3) Update translation files for your favorite language, a new set of strings must show up corresponding to names and descriptions on value builders. Note: messed up patches, sending again. --- .../intranet-tmpl/prog/en/js/xmlControlfield.js | 23 +- .../cataloguing/value_builder/marc21_field_006.xml | 1562 ++++++------ .../cataloguing/value_builder/marc21_field_008.xml | 2566 ++++++++++---------- .../cataloguing/value_builder/marc21_field_CF.xsd | 26 +- 4 files changed, 2092 insertions(+), 2085 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/xmlControlfield.js b/koha-tmpl/intranet-tmpl/prog/en/js/xmlControlfield.js index 608b79b..eccdba4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/xmlControlfield.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/xmlControlfield.js @@ -241,7 +241,7 @@ function changeH4Result(form, h4_result, tr_result, pos, value) var arrEquiv = new Array(); for (var i=0; i < nodeMaterial.length; i++) { id = nodeMaterial[i].attributes.getNamedItem("id").nodeValue; - name = nodeMaterial[i].attributes.getNamedItem("name").nodeValue; + name = nodeMaterial[i].getElementsByTagName('name')[0].textContent; arrEquiv[id] = i; arrSort.push(id); } @@ -249,7 +249,7 @@ function changeH4Result(form, h4_result, tr_result, pos, value) var j; for (var i=0; i < arrSort.length; i++) { j = arrEquiv[arrSort[i]]; - add_option(this.select, arrSort[i] + " - " + nodeMaterial[j].attributes.getNamedItem("name").nodeValue, arrSort[i], (this.idMaterial != "" && arrSort[i] == this.idMaterial)?true:false); + add_option(this.select, arrSort[i] + " - " + nodeMaterial[j].getElementsByTagName('name')[0].textContent, arrSort[i], (this.idMaterial != "" && arrSort[i] == this.idMaterial)?true:false); } } else if (this.idMaterial != "") { for (var i=0; i < this.select.options.length; i++) { @@ -292,16 +292,21 @@ function changeH4Result(form, h4_result, tr_result, pos, value) var selected; var index; var url; + var description; + var name; while (nodePos != null) { if (nodePos.nodeType == 1 && nodePos.nodeName == "Position") { tr = tbody.insertRow(tbody.rows.length); td = tr.insertCell(tr.cells.length); pos = nodePos.attributes.getNamedItem("pos").nodeValue; - title = ((nodePos.getAttributeNode("description") || nodePos.hasAttribute("description")) && nodePos.getAttribute("description") != "")?nodePos.attributes.getNamedItem("description").nodeValue:nodePos.attributes.getNamedItem("name").nodeValue; + // description is required by schema + description = nodePos.getElementsByTagName('description')[0].textContent; + name = nodePos.getElementsByTagName('name')[0].textContent + title = ( description != "")?description:name; try { - url = ((nodePos.getAttributeNode("url") || nodePos.hasAttribute("url")) && nodePos.getAttribute("url") != "" && nodePos.getAttribute("urltext") != "")?" " + nodePos.attributes.getNamedItem("urltext").nodeValue + "":""; + url = ((nodePos.getAttributeNode("url") || nodePos.hasAttribute("url")) && nodePos.getAttribute("url") != "" && nodePos.getElementsByTagName('urltext')[0].textContent != "")?" " + nodePos.getElementsByTagName('urltext')[0].textContent + "":""; } catch (e) { url = "";} - td.innerHTML = ""; + td.innerHTML = ""; td = tr.insertCell(tr.cells.length); value = returnValuePosFromResult(result, pos); if ((index = pos.indexOf("-")) > 0) { // Position interval @@ -312,14 +317,16 @@ function changeH4Result(form, h4_result, tr_result, pos, value) } else { strInnerHTML = "