Add merging of localized ils_events.xml descriptions to "install" target
authordbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 9 Sep 2008 14:46:40 +0000 (14:46 +0000)
committerdbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 9 Sep 2008 14:46:40 +0000 (14:46 +0000)
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
build/i18n/scripts/merge_ils_events.py [changed mode: 0644->0755]

index 30d2e68..30ec880 100644 (file)
@@ -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)
old mode 100644 (file)
new mode 100755 (executable)
index e24920d..8f02505
@@ -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()