Commit 8f3a88fb authored by root's avatar root

Set mime-type or svn-eol property from cvs expansion data

parent a9a59256
<dtml-var standard_html_header> <dtml-var standard_html_header>
<a href="tableNamed/&dtml.url_quote-Name;/manage_designInput">Design Input *</a> <a href="tableNamed/&dtml.url_quote-Name;/manage_designInput">Design Input *</a>
<a href="tableNamed/&dtml.url_quote-Name;/manage_designUpdate">Design Update *</a> <a href="tableNamed/&dtml.url_quote-Name;/manage_designUpdate">Design Update *</a>
<a href="tableNamed/&dtml.url_quote-Name;/manage_designDelete">Design Delete</a> <a href="tableNamed/&dtml.url_quote-Name;/manage_designDelete">Design Delete</a>
<dtml-var standard_html_footer> <dtml-var standard_html_footer>
#!/usr/bin/env python #!/usr/bin/env python
############################################################################## ##############################################################################
# #
# Copyright (c) 2002 Zope Corporation and Contributors. # Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved. # All Rights Reserved.
# #
# This software is subject to the provisions of the Zope Public License, # This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE. # FOR A PARTICULAR PURPOSE.
# #
############################################################################## ##############################################################################
"""Program to extract internationalization markup from Page Templates. """Program to extract internationalization markup from Page Templates.
Once you have marked up a Page Template file with i18n: namespace tags, use Once you have marked up a Page Template file with i18n: namespace tags, use
this program to extract GNU gettext .po file entries. this program to extract GNU gettext .po file entries.
Usage: talgettext.py [options] files Usage: talgettext.py [options] files
Options: Options:
-h / --help -h / --help
Print this message and exit. Print this message and exit.
-o / --output <file> -o / --output <file>
Output the translation .po file to <file>. Output the translation .po file to <file>.
-u / --update <file> -u / --update <file>
Update the existing translation <file> with any new translation strings Update the existing translation <file> with any new translation strings
found. found.
""" """
import sys import sys
import time import time
import getopt import getopt
import traceback import traceback
from TAL.HTMLTALParser import HTMLTALParser from TAL.HTMLTALParser import HTMLTALParser
from TAL.TALInterpreter import TALInterpreter from TAL.TALInterpreter import TALInterpreter
from TAL.DummyEngine import DummyEngine from TAL.DummyEngine import DummyEngine
from ITALES import ITALESEngine from ITALES import ITALESEngine
from TAL.TALDefs import TALESError from TAL.TALDefs import TALESError
__version__ = '$Revision: 1.2 $' __version__ = '$Revision: 1.2 $'
pot_header = '''\ pot_header = '''\
# SOME DESCRIPTIVE TITLE. # SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION # Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\\n" "Project-Id-Version: PACKAGE VERSION\\n"
"POT-Creation-Date: %(time)s\\n" "POT-Creation-Date: %(time)s\\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n"
"Language-Team: LANGUAGE <LL@li.org>\\n" "Language-Team: LANGUAGE <LL@li.org>\\n"
"MIME-Version: 1.0\\n" "MIME-Version: 1.0\\n"
"Content-Type: text/plain; charset=CHARSET\\n" "Content-Type: text/plain; charset=CHARSET\\n"
"Content-Transfer-Encoding: ENCODING\\n" "Content-Transfer-Encoding: ENCODING\\n"
"Generated-By: talgettext.py %(version)s\\n" "Generated-By: talgettext.py %(version)s\\n"
''' '''
NLSTR = '"\n"' NLSTR = '"\n"'
try: try:
True True
except NameError: except NameError:
True=1 True=1
False=0 False=0
def usage(code, msg=''): def usage(code, msg=''):
# Python 2.1 required # Python 2.1 required
print >> sys.stderr, __doc__ print >> sys.stderr, __doc__
if msg: if msg:
print >> sys.stderr, msg print >> sys.stderr, msg
sys.exit(code) sys.exit(code)
class POTALInterpreter(TALInterpreter): class POTALInterpreter(TALInterpreter):
def translate(self, msgid, default, i18ndict=None, obj=None): def translate(self, msgid, default, i18ndict=None, obj=None):
# XXX is this right? # XXX is this right?
if i18ndict is None: if i18ndict is None:
i18ndict = {} i18ndict = {}
if obj: if obj:
i18ndict.update(obj) i18ndict.update(obj)
# XXX Mmmh, it seems that sometimes the msgid is None; is that really # XXX Mmmh, it seems that sometimes the msgid is None; is that really
# possible? # possible?
if msgid is None: if msgid is None:
return None return None
# XXX We need to pass in one of context or target_language # XXX We need to pass in one of context or target_language
return self.engine.translate(msgid, self.i18nContext.domain, i18ndict, return self.engine.translate(msgid, self.i18nContext.domain, i18ndict,
position=self.position, default=default) position=self.position, default=default)
class POEngine(DummyEngine): class POEngine(DummyEngine):
__implements__ = ITALESEngine __implements__ = ITALESEngine
def __init__(self, macros=None): def __init__(self, macros=None):
self.catalog = {} self.catalog = {}
DummyEngine.__init__(self, macros) DummyEngine.__init__(self, macros)
def evaluate(*args): def evaluate(*args):
return '' # who cares return '' # who cares
def evaluatePathOrVar(*args): def evaluatePathOrVar(*args):
return '' # who cares return '' # who cares
def evaluateSequence(self, expr): def evaluateSequence(self, expr):
return (0,) # dummy return (0,) # dummy
def evaluateBoolean(self, expr): def evaluateBoolean(self, expr):
return True # dummy return True # dummy
def translate(self, msgid, domain=None, mapping=None, default=None, def translate(self, msgid, domain=None, mapping=None, default=None,
# XXX position is not part of the ITALESEngine # XXX position is not part of the ITALESEngine
# interface # interface
position=None): position=None):
if domain not in self.catalog: if domain not in self.catalog:
self.catalog[domain] = {} self.catalog[domain] = {}
domain = self.catalog[domain] domain = self.catalog[domain]
if msgid not in domain: if msgid not in domain:
domain[msgid] = [] domain[msgid] = []
domain[msgid].append((self.file, position)) domain[msgid].append((self.file, position))
return 'x' return 'x'
class UpdatePOEngine(POEngine): class UpdatePOEngine(POEngine):
"""A slightly-less braindead POEngine which supports loading an existing """A slightly-less braindead POEngine which supports loading an existing
.po file first.""" .po file first."""
def __init__ (self, macros=None, filename=None): def __init__ (self, macros=None, filename=None):
POEngine.__init__(self, macros) POEngine.__init__(self, macros)
self._filename = filename self._filename = filename
self._loadFile() self._loadFile()
self.base = self.catalog self.base = self.catalog
self.catalog = {} self.catalog = {}
def __add(self, id, s, fuzzy): def __add(self, id, s, fuzzy):
"Add a non-fuzzy translation to the dictionary." "Add a non-fuzzy translation to the dictionary."
if not fuzzy and str: if not fuzzy and str:
# check for multi-line values and munge them appropriately # check for multi-line values and munge them appropriately
if '\n' in s: if '\n' in s:
lines = s.rstrip().split('\n') lines = s.rstrip().split('\n')
s = NLSTR.join(lines) s = NLSTR.join(lines)
self.catalog[id] = s self.catalog[id] = s
def _loadFile(self): def _loadFile(self):
# shamelessly cribbed from Python's Tools/i18n/msgfmt.py # shamelessly cribbed from Python's Tools/i18n/msgfmt.py
# 25-Mar-2003 Nathan R. Yergler (nathan@zope.org) # 25-Mar-2003 Nathan R. Yergler (nathan@zope.org)
# 14-Apr-2003 Hacked by Barry Warsaw (barry@zope.com) # 14-Apr-2003 Hacked by Barry Warsaw (barry@zope.com)
ID = 1 ID = 1
STR = 2 STR = 2
try: try:
lines = open(self._filename).readlines() lines = open(self._filename).readlines()
except IOError, msg: except IOError, msg:
print >> sys.stderr, msg print >> sys.stderr, msg
sys.exit(1) sys.exit(1)
section = None section = None
fuzzy = False fuzzy = False
# Parse the catalog # Parse the catalog
lno = 0 lno = 0
for l in lines: for l in lines:
lno += True lno += True
# If we get a comment line after a msgstr, this is a new entry # If we get a comment line after a msgstr, this is a new entry
if l[0] == '#' and section == STR: if l[0] == '#' and section == STR:
self.__add(msgid, msgstr, fuzzy) self.__add(msgid, msgstr, fuzzy)
section = None section = None
fuzzy = False fuzzy = False
# Record a fuzzy mark # Record a fuzzy mark
if l[:2] == '#,' and l.find('fuzzy'): if l[:2] == '#,' and l.find('fuzzy'):
fuzzy = True fuzzy = True
# Skip comments # Skip comments
if l[0] == '#': if l[0] == '#':
continue continue
# Now we are in a msgid section, output previous section # Now we are in a msgid section, output previous section
if l.startswith('msgid'): if l.startswith('msgid'):
if section == STR: if section == STR:
self.__add(msgid, msgstr, fuzzy) self.__add(msgid, msgstr, fuzzy)
section = ID section = ID
l = l[5:] l = l[5:]
msgid = msgstr = '' msgid = msgstr = ''
# Now we are in a msgstr section # Now we are in a msgstr section
elif l.startswith('msgstr'): elif l.startswith('msgstr'):
section = STR section = STR
l = l[6:] l = l[6:]
# Skip empty lines # Skip empty lines
if not l.strip(): if not l.strip():
continue continue
# XXX: Does this always follow Python escape semantics? # XXX: Does this always follow Python escape semantics?
l = eval(l) l = eval(l)
if section == ID: if section == ID:
msgid += l msgid += l
elif section == STR: elif section == STR:
msgstr += '%s\n' % l msgstr += '%s\n' % l
else: else:
print >> sys.stderr, 'Syntax error on %s:%d' % (infile, lno), \ print >> sys.stderr, 'Syntax error on %s:%d' % (infile, lno), \
'before:' 'before:'
print >> sys.stderr, l print >> sys.stderr, l
sys.exit(1) sys.exit(1)
# Add last entry # Add last entry
if section == STR: if section == STR:
self.__add(msgid, msgstr, fuzzy) self.__add(msgid, msgstr, fuzzy)
def evaluate(self, expression): def evaluate(self, expression):
try: try:
return POEngine.evaluate(self, expression) return POEngine.evaluate(self, expression)
except TALESError: except TALESError:
pass pass
def evaluatePathOrVar(self, expr): def evaluatePathOrVar(self, expr):
return 'who cares' return 'who cares'
def translate(self, msgid, domain=None, mapping=None, default=None, def translate(self, msgid, domain=None, mapping=None, default=None,
position=None): position=None):
if msgid not in self.base: if msgid not in self.base:
POEngine.translate(self, msgid, domain, mapping, default, position) POEngine.translate(self, msgid, domain, mapping, default, position)
return 'x' return 'x'
def main(): def main():
try: try:
opts, args = getopt.getopt( opts, args = getopt.getopt(
sys.argv[1:], sys.argv[1:],
'ho:u:', 'ho:u:',
['help', 'output=', 'update=']) ['help', 'output=', 'update='])
except getopt.error, msg: except getopt.error, msg:
usage(1, msg) usage(1, msg)
outfile = None outfile = None
engine = None engine = None
update_mode = False update_mode = False
for opt, arg in opts: for opt, arg in opts:
if opt in ('-h', '--help'): if opt in ('-h', '--help'):
usage(0) usage(0)
elif opt in ('-o', '--output'): elif opt in ('-o', '--output'):
outfile = arg outfile = arg
elif opt in ('-u', '--update'): elif opt in ('-u', '--update'):
update_mode = True update_mode = True
if outfile is None: if outfile is None:
outfile = arg outfile = arg
engine = UpdatePOEngine(filename=arg) engine = UpdatePOEngine(filename=arg)
if not args: if not args:
print 'nothing to do' print 'nothing to do'
return return
# We don't care about the rendered output of the .pt file # We don't care about the rendered output of the .pt file
class Devnull: class Devnull:
def write(self, s): def write(self, s):
pass pass
# check if we've already instantiated an engine; # check if we've already instantiated an engine;
# if not, use the stupidest one available # if not, use the stupidest one available
if not engine: if not engine:
engine = POEngine() engine = POEngine()
# process each file specified # process each file specified
for filename in args: for filename in args:
try: try:
engine.file = filename engine.file = filename
p = HTMLTALParser() p = HTMLTALParser()
p.parseFile(filename) p.parseFile(filename)
program, macros = p.getCode() program, macros = p.getCode()
POTALInterpreter(program, macros, engine, stream=Devnull(), POTALInterpreter(program, macros, engine, stream=Devnull(),
metal=False)() metal=False)()
except: # Hee hee, I love bare excepts! except: # Hee hee, I love bare excepts!
print 'There was an error processing', filename print 'There was an error processing', filename
traceback.print_exc() traceback.print_exc()
# Now output the keys in the engine. Write them to a file if --output or # Now output the keys in the engine. Write them to a file if --output or
# --update was specified; otherwise use standard out. # --update was specified; otherwise use standard out.
if (outfile is None): if (outfile is None):
outfile = sys.stdout outfile = sys.stdout
else: else:
outfile = file(outfile, update_mode and "a" or "w") outfile = file(outfile, update_mode and "a" or "w")
catalog = {} catalog = {}
for domain in engine.catalog.keys(): for domain in engine.catalog.keys():
catalog.update(engine.catalog[domain]) catalog.update(engine.catalog[domain])
messages = catalog.copy() messages = catalog.copy()
try: try:
messages.update(engine.base) messages.update(engine.base)
except AttributeError: except AttributeError:
pass pass
if '' not in messages: if '' not in messages:
print >> outfile, pot_header % {'time': time.ctime(), print >> outfile, pot_header % {'time': time.ctime(),
'version': __version__} 'version': __version__}
msgids = catalog.keys() msgids = catalog.keys()
# XXX: You should not sort by msgid, but by filename and position. (SR) # XXX: You should not sort by msgid, but by filename and position. (SR)
msgids.sort() msgids.sort()
for msgid in msgids: for msgid in msgids:
positions = catalog[msgid] positions = catalog[msgid]
for filename, position in positions: for filename, position in positions:
outfile.write('#: %s:%s\n' % (filename, position[0])) outfile.write('#: %s:%s\n' % (filename, position[0]))
outfile.write('msgid "%s"\n' % msgid) outfile.write('msgid "%s"\n' % msgid)
outfile.write('msgstr ""\n') outfile.write('msgstr ""\n')
outfile.write('\n') outfile.write('\n')
if __name__ == '__main__': if __name__ == '__main__':
main() main()
# -*- coding: iso-8859-1 -*- # -*- coding: iso-8859-1 -*-
# Author: Marcelo Huerta San Martn # Author: Marcelo Huerta San Martn
# Contact: mghsm@uol.com.ar # Contact: mghsm@uol.com.ar
# Revision: $Revision: 1.3 $ # Revision: $Revision: 1.3 $
# Date: $Date: 2003/11/30 15:06:05 $ # Date: $Date: 2003/11/30 15:06:05 $
# Copyright: This module has been placed in the public domain. # Copyright: This module has been placed in the public domain.
# New language mappings are welcome. Before doing a new translation, please # New language mappings are welcome. Before doing a new translation, please
# read <http://docutils.sf.net/spec/howto/i18n.html>. Two files must be # read <http://docutils.sf.net/spec/howto/i18n.html>. Two files must be
# translated for each language: one in docutils/languages, the other in # translated for each language: one in docutils/languages, the other in
# docutils/parsers/rst/languages. # docutils/parsers/rst/languages.
""" """
Spanish-language mappings for language-dependent features of Docutils. Spanish-language mappings for language-dependent features of Docutils.
""" """
__docformat__ = 'reStructuredText' __docformat__ = 'reStructuredText'
labels = { labels = {
'author': u'Autor', 'author': u'Autor',
'authors': u'Autores', 'authors': u'Autores',
'organization': u'Organizaci\u00f3n', 'organization': u'Organizaci\u00f3n',
'address': u'Direcci\u00f3n', 'address': u'Direcci\u00f3n',
'contact': u'Contacto', 'contact': u'Contacto',
'version': u'Versi\u00f3n', 'version': u'Versi\u00f3n',
'revision': u'Revisi\u00f3n', 'revision': u'Revisi\u00f3n',
'status': u'Estado', 'status': u'Estado',
'date': u'Fecha', 'date': u'Fecha',
'copyright': u'Copyright', 'copyright': u'Copyright',
'dedication': u'Dedicatoria', 'dedication': u'Dedicatoria',
'abstract': u'Resumen', 'abstract': u'Resumen',
'attention': u'\u00a1Atenci\u00f3n!', 'attention': u'\u00a1Atenci\u00f3n!',
'caution': u'\u00a1Precauci\u00f3n!', 'caution': u'\u00a1Precauci\u00f3n!',
'danger': u'\u00a1PELIGRO!', 'danger': u'\u00a1PELIGRO!',
'error': u'Error', 'error': u'Error',
'hint': u'Sugerencia', 'hint': u'Sugerencia',
'important': u'Importante', 'important': u'Importante',
'note': u'Nota', 'note': u'Nota',
'tip': u'Consejo', 'tip': u'Consejo',
'warning': u'Advertencia', 'warning': u'Advertencia',
'contents': u'Contenido'} 'contents': u'Contenido'}
"""Mapping of node class name to label text.""" """Mapping of node class name to label text."""
bibliographic_fields = { bibliographic_fields = {
u'autor': 'author', u'autor': 'author',
u'autores': 'authors', u'autores': 'authors',
u'organizaci\u00f3n': 'organization', u'organizaci\u00f3n': 'organization',
u'direcci\u00f3n': 'address', u'direcci\u00f3n': 'address',
u'contacto': 'contact', u'contacto': 'contact',
u'versi\u00f3n': 'version', u'versi\u00f3n': 'version',
u'revisi\u00f3n': 'revision', u'revisi\u00f3n': 'revision',
u'estado': 'status', u'estado': 'status',
u'fecha': 'date', u'fecha': 'date',
u'copyright': 'copyright', u'copyright': 'copyright',
u'dedicatoria': 'dedication', u'dedicatoria': 'dedication',
u'resumen': 'abstract'} u'resumen': 'abstract'}
"""Spanish (lowcased) to canonical name mapping for bibliographic fields.""" """Spanish (lowcased) to canonical name mapping for bibliographic fields."""
author_separators = [';', ','] author_separators = [';', ',']
"""List of separator strings for the 'Authors' bibliographic field. Tried in """List of separator strings for the 'Authors' bibliographic field. Tried in
order.""" order."""
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment