/[opental]/opental/OpenPTi18n/i18n_xgettext.py
ViewVC logotype

Diff of /opental/OpenPTi18n/i18n_xgettext.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by lalo, Fri Jan 24 21:02:56 2003 UTC revision 1.8 by lalo, Fri Jan 24 21:22:11 2003 UTC
# Line 50  timezone = '%02d%02d' % (int(time.timezo Line 50  timezone = '%02d%02d' % (int(time.timezo
50  if time.timezone >= 0:  if time.timezone >= 0:
51      timezone = '+' + timezone      timezone = '+' + timezone
52  # header for potfiles  # header for potfiles
53    global potfile_header
54  potfile_header = r'''  potfile_header = r'''
55  # Gettext Message File for Plone.  # Gettext Message File for %(domain)s.
56  # Your Name <your@email>, Year  # Your Name <your@email>, Year
57  EDIT the lines below correctly (and DELETE this one) or your translation WILL NOT WORK  EDIT the lines below correctly (and DELETE this one) or your translation WILL NOT WORK
58  msgid ""  msgid ""
59  msgstr ""  msgstr ""
60  "Project-Id-Version: Plone 1.0\n"  "Project-Id-Version: %(domain)s\n"
61  "POT-Creation-Date: %s%s\n"  "POT-Creation-Date: %(timestamp)s%(domain)s\n"
62  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
63  "Last-Translator: Your Name <your@email>\n"  "Last-Translator: Your Name <your@email>\n"
64  "Language-Team: Plone i18n <plone-i18n@lists.sourceforge.net>\n"  "Language-Team: Name <email>\n"
65  "MIME-Version: 1.0\n"  "MIME-Version: 1.0\n"
66  "Content-Type: text/plain; charset=CHARSET\n"  "Content-Type: text/plain; charset=CHARSET\n"
67  "Content-Transfer-Encoding: 8bit\n"  "Content-Transfer-Encoding: 8bit\n"
# Line 68  msgstr "" Line 69  msgstr ""
69  "Language-code: LL\n"  "Language-code: LL\n"
70  "Language-name: Language\n"  "Language-name: Language\n"
71  "Preferred-encodings: utf-8 latin1\n"  "Preferred-encodings: utf-8 latin1\n"
72  "Domain: plone\n"  "Domain: %(domain)s\n"
73  -------------- Delete this line too just to prove you paid attention --------------  -------------- Delete this line too just to prove you paid attention --------------
74    
75  '''[1:] % (time.strftime('%Y-%m-%d %H:%M', time.localtime()), timezone)  '''[1:]
76    
77  # other pax-related variables  # other pax-related variables
78  tal_ns = tal_handler.ns  tal_ns = tal_handler.ns
79  namespaces = {'i18n': i18n_ns, tal_handler.name: tal_ns}  namespaces = {'i18n': i18n_ns, tal_handler.name: tal_ns}
# Line 232  def _do_dir(info, dirname, names): Line 234  def _do_dir(info, dirname, names):
234              _do_file(os.path.join(dirname, name), catalog)              _do_file(os.path.join(dirname, name), catalog)
235    
236    
237  def xgettext(paths, filenames=filenames, output=None, use_default=None):  def xgettext(paths, filenames=filenames, output=None, domain='default', use_default=None):
238      if type(output) is types.StringType:      if type(output) is types.StringType:
239          # this is done first because if it raises an exception,          # this is done first because if it raises an exception,
240          # we haven't yet read potentially hundreds of files and          # we haven't yet read potentially hundreds of files and
# Line 259  if __name__ == '__main__': Line 261  if __name__ == '__main__':
261      import getopt      import getopt
262      try:      try:
263          opts, paths = getopt.getopt(sys.argv[1:],          opts, paths = getopt.getopt(sys.argv[1:],
264                                     'f:ho:d',                                     'f:ho:dD:',
265                                     'filenames= help output= use-default'.split())                                     'filenames= help output= use-default domain='.split())
266      except getopt.GetoptError, e:      except getopt.GetoptError, e:
267          print e.msg          print e.msg
268          print          print
269          _help()          _help()
270    
271      use_default = None      use_default = None
272        output = None
273        domain = 'default'
274      for opt, value in opts:      for opt, value in opts:
275          if opt in ('-f', '--filenames'):          if opt in ('-f', '--filenames'):
276              filenames = value              filenames = value
# Line 277  if __name__ == '__main__': Line 281  if __name__ == '__main__':
281              output = value              output = value
282          elif opt in ('-d', '--use-default'):          elif opt in ('-d', '--use-default'):
283              use_default = 1              use_default = 1
284            elif opt in ('-D', '--domain'):
285                domain = value
286        if output is None:
287            output = domain + '.pot'
288        global potfile_header
289        potfile_header = potfile_header % {
290            'timestamp':time.strftime('%Y-%m-%d %H:%M', time.localtime()),
291            'tz':timezone,
292            'domain':domain}
293    
294      try:      try:
295          xgettext(paths, filenames, output, use_default)          xgettext(paths, filenames, output, domain, use_default)
296      except ProcessError:      except ProcessError:
297            import traceback
298            traceback.print_exc()
299          sys.exit(1)          sys.exit(1)

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26