From 1524fe6850716b7df4aa2d623cf3d2f74cac33f4 Mon Sep 17 00:00:00 2001 From: Bernardo Gonzalez Kriegel Date: Sat, 27 Apr 2013 15:42:39 -0300 Subject: [PATCH] [PASSED QA] 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. 3) Adds xml processing to translation script 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. Signed-off-by: Tomas Cohen Arazi Signoff notes: Tested both value builders. They work as expected. Running $ perl translate update es-ES resulted in the xml string being added to the relevant .po file (the staff one). No koha-qa.pl errors BTW. To-. Signed-off-by: Katrin Fischer All tests and QA script pass. Did regression tests on the plugins for 006 and 008 and could spot not difference to behaviour before. Also tested the translation process and found it working nicely. Thank you for fixing this long standing translation bug! --- .../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 +- misc/translator/tmpl_process3.pl | 2 +- 5 files changed, 2093 insertions(+), 2086 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 = "