home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / share / xml2po / gs.py < prev    next >
Encoding:
Python Source  |  2007-04-09  |  3.0 KB  |  84 lines

  1. # Copyright (c) 2004, 2005, 2006 Danilo Segan <danilo@gnome.org>.
  2. #
  3. # This file is part of xml2po.
  4. #
  5. # xml2po is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # xml2po is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with xml2po; if not, write to the Free Software Foundation, Inc.,
  17. # 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  18. #
  19.  
  20. # Special case Gnome Summary
  21. #
  22.  
  23. class gsXmlMode:
  24.     """Abstract class for special handling of document types."""
  25.     def getIgnoredTags(self):
  26.         "Returns array of tags to be ignored."
  27.         return [ 'link', 'bug-stats', 'cvs-stats', 'unixname' ]
  28.  
  29.     def getFinalTags(self):
  30.         "Returns array of tags to be considered 'final'."
  31.         return ['title', 'para', 'name', 'desc' ]
  32.  
  33.     def getSpacePreserveTags(self):
  34.         "Returns array of tags in which spaces are to be preserved."
  35.         return []
  36.  
  37.     def getTreatedAttributes(self):
  38.         "Returns array of tag attributes which content is to be translated"
  39.         return []
  40.  
  41.     def preProcessXml(self, doc, msg):
  42.         "Preprocess a document and perhaps adds some messages."
  43.         pass
  44.  
  45.     def _find_salute(self, node):
  46.         if node.name == 'salute':
  47.             return node
  48.         child = node.children
  49.         while child:
  50.             ret = self._find_salute(child)
  51.             if ret:
  52.                 return ret
  53.             child = child.next
  54.         return None
  55.  
  56.     def postProcessXmlTranslation(self, doc, language, translators):
  57.         """Sets a language and translators in "doc" tree.
  58.         
  59.         "translators" is a string consisted of translator credits.
  60.         "language" is a simple string.
  61.         "doc" is a libxml2.xmlDoc instance."""
  62.         # Find "salute" tag and add a comment about translator.
  63.         if translators == self.getStringForTranslators():
  64.             return
  65.         else:
  66.             salute = self._find_salute(doc.getRootElement())
  67.             if salute and salute.name=='salute':
  68.                 # found
  69.                 salute.newChild(None, "para", translators)
  70.             else:
  71.                 return
  72.  
  73.     def getStringForTranslators(self):
  74.         """Returns None or a string to be added to PO files.
  75.  
  76.         Common example is 'translator-credits'."""
  77.         return "translator-credits"
  78.  
  79.     def getCommentForTranslators(self):
  80.         """Returns a comment to be added next to string for crediting translators.
  81.  
  82.         It should explain the format of the string provided by getStringForTranslators()."""
  83.         return """Translators: enter a short paragraph creditting yourself and others who helped you with the translation."""
  84.