[gimp-help-2] [xml2po] Add and use new xml2mode "gimphelp"



commit 0f67d57dfded3876b7dd42ebd035047e1e28e254
Author: Ulf-D. Ehlert <ulfehlert svn gnome org>
Date:   Wed Dec 16 20:34:25 2009 +0100

    [xml2po] Add and use new xml2mode "gimphelp"

 Makefile.GNU                   |   15 +++++-----
 tools/xml2po/modes/gimphelp.py |   59 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 67 insertions(+), 7 deletions(-)
---
diff --git a/Makefile.GNU b/Makefile.GNU
index a2051fa..e151cee 100644
--- a/Makefile.GNU
+++ b/Makefile.GNU
@@ -28,12 +28,13 @@ XSLTFLAGS = --nonet
 XMLLINT      = xmllint
 XMLLINTFLAGS = --nonet
 
-XML2PO = tools/xml2po.py
+XML2PO        = tools/xml2po.py
+XML2POFLAGS   = --mode=gimphelp
 
 MSGWIDTH      = 79
-MSGUNIQ       = msguniq 
-MSGUNIQFLAGS  = 
-MSGCAT        = msgcat 
+MSGUNIQ       = msguniq
+MSGUNIQFLAGS  =
+MSGCAT        = msgcat
 MSGCATFLAGS   = --width=$(MSGWIDTH)
 MSGINIT       = msginit
 MSGINITFLAGS  = --no-translator --width=$(MSGWIDTH)
@@ -151,7 +152,7 @@ endif
 #
 # Hint: Better don't use 'grep' for filtering-out the warning
 # messages, since grep's exit status is 1 if there is no match.
-xml2pot = ($(XML2PO) --output='-' $(1) \
+xml2pot = ($(XML2PO) $(XML2POFLAGS) --output='-' $(1) \
           | $(MSGUNIQ) $(MSGUNIQFLAGS) \
           | $(MSGCAT) $(MSGCATFLAGS) - > "$(2)") 2>&1 \
           | $(SED) -e '/image file .* not found/d'; \
@@ -200,11 +201,11 @@ pot2po = with_compendium="$(shell $(call get_compendium,$3)) \
 #     $3 - translation language
 #     $4 - resulting (translated) XML file
 ifneq ("$(FORMAT_XML_WITH_XMLLINT)", "1")
-po2xml = $(XML2PO) --po-file=$(2) --language=$(3) --output=$(4) $(1) 2>&1 \
+po2xml = $(XML2PO) $(XML2POFLAGS) --po-file=$(2) --language=$(3) --output=$(4) $(1) 2>&1 \
          | $(SED) -e '/Warning: image file .* not found./d'; \
          rm -f .xml2po.mo
 else
-po2xml = ($(XML2PO) --po-file=$(2) --language=$(3) --output='-' $(1) \
+po2xml = ($(XML2PO) $(XML2POFLAGS) --po-file=$(2) --language=$(3) --output='-' $(1) \
          | $(XMLLINT) $(XMLLINTFLAGS) --format --output $(4) -) 2>&1 \
          | $(SED) -e '/Warning: image file .* not found./d'; \
          rm -f .xml2po.mo
diff --git a/tools/xml2po/modes/gimphelp.py b/tools/xml2po/modes/gimphelp.py
new file mode 100644
index 0000000..fe92f69
--- /dev/null
+++ b/tools/xml2po/modes/gimphelp.py
@@ -0,0 +1,59 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2004, 2005, 2006 Danilo Segan <danilo gnome org>.
+#
+# This file is part of xml2po.
+#
+# xml2po is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# xml2po is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with xml2po; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+# Adapted for the GIMP Manual's build system 2009-12-14
+# (c) 2009 The GIMP Documenation Team
+#
+
+import re
+import libxml2
+import os
+import sys
+try:
+    # Hashlib is new in Python 2.5
+    from hashlib import md5 as md5_new
+except ImportError:
+    from md5 import new as md5_new
+
+from docbook import docbookXmlMode
+
+class gimphelpXmlMode(docbookXmlMode):
+    """Class for special handling of gimp-help DocBook document types.
+
+    It sets lang attribute on article elements, and adds translators
+    to articleinfo/copyright."""
+    def __init__(self):
+        try:
+            super(gimphelpXmlMode, self).__init__()
+        except TypeError:
+            self.lists = ['itemizedlist', 'orderedlist', 'variablelist',
+                          'segmentedlist', 'simplelist', 'calloutlist', 'varlistentry' ]
+            self.objects = [ 'figure', 'textobject', 'imageobject', 'mediaobject',
+                             'screenshot' ]
+
+# Perform some tests when ran standalone
+if __name__ == '__main__':
+    test = gimphelpXmlMode()
+    print "Ignored tags       : " + repr(test.getIgnoredTags())
+    print "Final tags         : " + repr(test.getFinalTags())
+    print "Space-preserve tags: " + repr(test.getSpacePreserveTags())
+
+    print "Credits from string: '%s'" % test.getStringForTranslators()
+    print "Explanation for credits:\n\t'%s'" % test.getCommentForTranslators()
+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]