From f2f10ef9f11260707a60ef9725d3fcbdea62fcc5 Mon Sep 17 00:00:00 2001 From: dbs Date: Tue, 9 Sep 2008 14:46:40 +0000 Subject: [PATCH] Add merging of localized ils_events.xml descriptions to "install" target Prevent repeated merging of localized ils_events.xml descriptions from adding duplicate descriptions git-svn-id: svn://svn.open-ils.org/ILS/trunk@10565 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- build/i18n/Makefile.in | 2 +- build/i18n/scripts/merge_ils_events.py | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) mode change 100644 => 100755 build/i18n/scripts/merge_ils_events.py diff --git a/build/i18n/Makefile.in b/build/i18n/Makefile.in index 30d2e687c8..30ec88065d 100644 --- a/build/i18n/Makefile.in +++ b/build/i18n/Makefile.in @@ -127,4 +127,4 @@ install: updatepo project cp $(PROJECT)/$(LOCALE)/lang.dtd $(CHROME_PROPSDIR)/$(LOCALE)/ cp $(PROJECT)/$(LOCALE)/lang.dtd $(DTDDIR)/$(LOCALE)/ cp $(PROJECT)/$(LOCALE)/opac.dtd $(DTDDIR)/$(LOCALE)/ - + @scripts/merge_ils_events.py --master $(EVTSRC) --localization $(PROJECT)/$(LOCALE)/$(EVTXML) --output $(EVTSRC) diff --git a/build/i18n/scripts/merge_ils_events.py b/build/i18n/scripts/merge_ils_events.py old mode 100644 new mode 100755 index e24920df9d..8f02505635 --- a/build/i18n/scripts/merge_ils_events.py +++ b/build/i18n/scripts/merge_ils_events.py @@ -19,8 +19,15 @@ def merge_events(master, localization): events = master_xml.getElementsByTagName('event') for event in events: + merged.documentElement.appendChild(merged.createTextNode("\n")) + l10n_node = get_l10n_event_desc(l10n_xml, event.getAttribute('code')) + for child in event.childNodes: + if child.nodeName == 'desc': + if child.getAttribute('xml:lang') == l10n_node.getAttribute('xml:lang'): + event.removeChild(child) + event.appendChild(l10n_node) merged.documentElement.appendChild(event) - event.appendChild(get_l10n_event_desc(l10n_xml, event.getAttribute('code'))) + merged.documentElement.appendChild(merged.createTextNode("\n")) return merged @@ -53,6 +60,8 @@ def main(): metavar='FILE') opts.add_option('-o', '--output', dest='outfile', \ help='Write output to FILE (defaults to STDOUT)', metavar='FILE') + opts.add_option('-p', '--pretty', action='store', \ + help='Write pretty XML output') (options, args) = opts.parse_args() if not options.master: @@ -64,9 +73,15 @@ def main(): if options.outfile: outfile = open(options.outfile, 'w') - outfile.write(merged.toprettyxml(encoding='utf-8')) + if options.pretty: + outfile.write(merged.toprettyxml(encoding='utf-8')) + else: + outfile.write(merged.toxml(encoding='utf-8')) else: - print merged.toprettyxml(encoding='utf-8') + if options.pretty: + print merged.toprettyxml(encoding='utf-8') + else: + print merged.toxml(encoding='utf-8') if __name__ == '__main__': main() -- 2.43.2