4 This class enables translation of Evergreen's seed database strings
5 and fieldmapper IDL XML.
7 Requires polib from http://polib.googlecode.com
9 # Copyright 2007 Dan Scott <dscott@laurentian.ca>
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License
13 # as published by the Free Software Foundation; either version 2
14 # of the License, or (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
26 Define the base class for localization support in Evergreen
30 self.pot = polib.POFile()
32 def pothead(self, version=None, date=None):
34 Initializes the header for a POT file to reasonable defaults
36 # We should be smarter about the Project-Id-Version attribute
38 version = 'Evergreen 1.4'
40 date = time.strftime("%Y-%m-%d %H:%M:%S") + '-0400'
41 self.pot.metadata['Project-Id-Version'] = version
42 self.pot.metadata['Report-Msgid-Bugs-To'] = \
43 'open-ils-dev@list.georgialibraries.org'
44 # Cheat and hard-code the time zone offset
45 self.pot.metadata['POT-Creation-Date'] = date
46 self.pot.metadata['PO-Revision-Date'] = 'YEAR-MO-DA HO:MI+ZONE'
47 self.pot.metadata['Last-Translator'] = 'FULL NAME <EMAIL@ADDRESS>'
48 self.pot.metadata['Language-Team'] = 'LANGUAGE <LL@li.org>'
49 self.pot.metadata['MIME-Version'] = '1.0'
50 self.pot.metadata['Content-Type'] = 'text/plain; charset=utf-8'
51 self.pot.metadata['Content-Transfer-Encoding'] = '8-bit'
53 def savepot(self, destination):
55 Saves the POT file to a specified file.
57 self.pot.save(destination)
59 def loadpo(self, source):
61 Loads a translated PO file so we can generate the corresponding SQL or entity definitions.
63 self.pot = polib.pofile(source)
67 Returns the PO representation of the strings.
69 return self.pot.__str__()