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):
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'
39 date = time.strftime("%Y-%m-%d %H:%M:%S")
40 self.pot.metadata['Project-Id-Version'] = version
41 self.pot.metadata['Report-Msgid-Bugs-To'] = \
42 'open-ils-dev@list.georgialibraries.org'
43 # Cheat and hard-code the time zone offset
44 self.pot.metadata['POT-Creation-Date'] = "%s %s" % (date, '-0400')
45 self.pot.metadata['PO-Revision-Date'] = 'YEAR-MO-DA HO:MI+ZONE'
46 self.pot.metadata['Last-Translator'] = 'FULL NAME <EMAIL@ADDRESS>'
47 self.pot.metadata['Language-Team'] = 'LANGUAGE <LL@li.org>'
48 self.pot.metadata['MIME-Version'] = '1.0'
49 self.pot.metadata['Content-Type'] = 'text/plain; charset=utf-8'
50 self.pot.metadata['Content-Transfer-Encoding'] = '8-bit'
52 def savepot(self, destination):
54 Saves the POT file to a specified file.
56 self.pot.save(destination)
58 def loadpo(self, source):
60 Loads a translated PO file so we can generate the corresponding SQL or entity definitions.
62 self.pot = polib.pofile(source)
66 Returns the PO representation of the strings.
68 return self.pot.__str__()