OSDN Git Service

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