* Add more generated text to the automatic translation.

* Remove all locale-dependent text from sphinx.sty, put it into Python files
  to enable message extraction and translation.
* Use babel in the LaTeX output.
* Centralize locations for labels used in every builder.
This commit is contained in:
Georg Brandl 2008-08-10 10:00:20 +00:00
parent e9d3589140
commit 74d36acbf7
19 changed files with 1104 additions and 398 deletions

View File

@ -99,8 +99,9 @@ General configuration
.. confval:: language .. confval:: language
The code for the language the docs are written in. Any text automatically The code for the language the docs are written in. Any text automatically
generated by Sphinx will be in that language. Default is ``None``, which generated by Sphinx will be in that language. Also, in the LaTeX builder, a
means that no translation will be done. suitable language will be selected as an option for the *Babel* package.
Default is ``None``, which means that no translation will be done.
.. versionadded:: 0.5 .. versionadded:: 0.5

View File

@ -25,7 +25,7 @@ from docutils.utils import new_document
from docutils.frontend import OptionParser from docutils.frontend import OptionParser
from docutils.readers.doctree import Reader as DoctreeReader from docutils.readers.doctree import Reader as DoctreeReader
from sphinx import addnodes, __version__ from sphinx import addnodes, locale, __version__
from sphinx.util import ensuredir, relative_uri, SEP, os_path, json from sphinx.util import ensuredir, relative_uri, SEP, os_path, json
from sphinx.htmlhelp import build_hhx from sphinx.htmlhelp import build_hhx
from sphinx.htmlwriter import HTMLWriter, HTMLTranslator, SmartyPantsHTMLTranslator from sphinx.htmlwriter import HTMLWriter, HTMLTranslator, SmartyPantsHTMLTranslator
@ -184,6 +184,7 @@ class Builder(object):
if self.translator is None: if self.translator is None:
self.translator = gettext.NullTranslations() self.translator = gettext.NullTranslations()
self.translator.install(unicode=True) self.translator.install(unicode=True)
locale.init() # translate common labels
def load_env(self): def load_env(self):
"""Set up the build environment.""" """Set up the build environment."""
@ -1085,9 +1086,9 @@ class ChangesBuilder(Builder):
apichanges.append((entry, docname, lineno)) apichanges.append((entry, docname, lineno))
elif descname or module: elif descname or module:
if not module: if not module:
module = 'Builtins' module = _('Builtins')
if not descname: if not descname:
descname = 'Module level' descname = _('Module level')
if context: if context:
entry = '<b>%s</b>: <i>%s:</i> %s' % (descname, ttext, context) entry = '<b>%s</b>: <i>%s:</i> %s' % (descname, ttext, context)
else: else:

View File

@ -23,14 +23,14 @@ ws_re = re.compile(r'\s+')
def desc_index_text(desctype, module, name): def desc_index_text(desctype, module, name):
if desctype == 'function': if desctype == 'function':
if not module: if not module:
return '%s() (built-in function)' % name return _('%s() (built-in function)') % name
return '%s() (in module %s)' % (name, module) return _('%s() (in module %s)') % (name, module)
elif desctype == 'data': elif desctype == 'data':
if not module: if not module:
return '%s (built-in variable)' % name return _('%s (built-in variable)') % name
return '%s (in module %s)' % (name, module) return _('%s (in module %s)') % (name, module)
elif desctype == 'class': elif desctype == 'class':
return '%s (class in %s)' % (name, module) return _('%s (class in %s)') % (name, module)
elif desctype == 'exception': elif desctype == 'exception':
return name return name
elif desctype == 'method': elif desctype == 'method':
@ -38,79 +38,83 @@ def desc_index_text(desctype, module, name):
clsname, methname = name.rsplit('.', 1) clsname, methname = name.rsplit('.', 1)
except ValueError: except ValueError:
if module: if module:
return '%s() (in module %s)' % (name, module) return _('%s() (in module %s)') % (name, module)
else: else:
return '%s()' % name return '%s()' % name
if module: if module:
return '%s() (%s.%s method)' % (methname, module, clsname) return _('%s() (%s.%s method)') % (methname, module, clsname)
else: else:
return '%s() (%s method)' % (methname, clsname) return _('%s() (%s method)') % (methname, clsname)
elif desctype == 'staticmethod': elif desctype == 'staticmethod':
try: try:
clsname, methname = name.rsplit('.', 1) clsname, methname = name.rsplit('.', 1)
except ValueError: except ValueError:
if module: if module:
return '%s() (in module %s)' % (name, module) return _('%s() (in module %s)') % (name, module)
else: else:
return '%s()' % name return '%s()' % name
if module: if module:
return '%s() (%s.%s static method)' % (methname, module, clsname) return _('%s() (%s.%s static method)') % (methname, module, clsname)
else: else:
return '%s() (%s static method)' % (methname, clsname) return _('%s() (%s static method)') % (methname, clsname)
elif desctype == 'attribute': elif desctype == 'attribute':
try: try:
clsname, attrname = name.rsplit('.', 1) clsname, attrname = name.rsplit('.', 1)
except ValueError: except ValueError:
if module: if module:
return '%s (in module %s)' % (name, module) return _('%s (in module %s)') % (name, module)
else: else:
return name return name
if module: if module:
return '%s (%s.%s attribute)' % (attrname, module, clsname) return _('%s (%s.%s attribute)') % (attrname, module, clsname)
else: else:
return '%s (%s attribute)' % (attrname, clsname) return _('%s (%s attribute)') % (attrname, clsname)
elif desctype == 'cfunction': elif desctype == 'cfunction':
return '%s (C function)' % name return _('%s (C function)') % name
elif desctype == 'cmember': elif desctype == 'cmember':
return '%s (C member)' % name return _('%s (C member)') % name
elif desctype == 'cmacro': elif desctype == 'cmacro':
return '%s (C macro)' % name return _('%s (C macro)') % name
elif desctype == 'ctype': elif desctype == 'ctype':
return '%s (C type)' % name return _('%s (C type)') % name
elif desctype == 'cvar': elif desctype == 'cvar':
return '%s (C variable)' % name return _('%s (C variable)') % name
else: else:
raise ValueError("unhandled descenv: %s" % desctype) raise ValueError('unhandled descenv: %s' % desctype)
# ------ make field lists (like :param foo:) in desc bodies prettier # ------ make field lists (like :param foo:) in desc bodies prettier
_ = lambda x: x # make gettext extraction in constants possible
doc_fields_with_arg = { doc_fields_with_arg = {
'param': 'param', 'param': '%param',
'parameter': 'param', 'parameter': '%param',
'arg': 'param', 'arg': '%param',
'argument': 'param', 'argument': '%param',
'keyword': 'param', 'keyword': '%param',
'kwarg': 'param', 'kwarg': '%param',
'kwparam': 'param', 'kwparam': '%param',
'type': 'type', 'type': '%type',
'raises': 'Raises', 'raises': _('Raises'),
'raise': 'Raises', 'raise': 'Raises',
'exception': 'Raises', 'exception': 'Raises',
'except': 'Raises', 'except': 'Raises',
'var': 'Variable', 'var': _('Variable'),
'ivar': 'Variable', 'ivar': 'Variable',
'cvar': 'Variable', 'cvar': 'Variable',
'returns': 'Returns', 'returns': _('Returns'),
'return': 'Returns', 'return': 'Returns',
} }
doc_fields_without_arg = { doc_fields_without_arg = {
'returns': 'Returns', 'returns': 'Returns',
'return': 'Returns', 'return': 'Returns',
'rtype': 'Return type', 'rtype': _('Return type'),
} }
del _
def handle_doc_fields(node): def handle_doc_fields(node):
# don't traverse, only handle field lists that are immediate children # don't traverse, only handle field lists that are immediate children
for child in node.children: for child in node.children:
@ -124,16 +128,16 @@ def handle_doc_fields(node):
fname, fbody = field fname, fbody = field
try: try:
typ, obj = fname.astext().split(None, 1) typ, obj = fname.astext().split(None, 1)
typ = doc_fields_with_arg[typ] typ = _(doc_fields_with_arg[typ])
if len(fbody.children) == 1 and \ if len(fbody.children) == 1 and \
isinstance(fbody.children[0], nodes.paragraph): isinstance(fbody.children[0], nodes.paragraph):
children = fbody.children[0].children children = fbody.children[0].children
else: else:
children = fbody.children children = fbody.children
if typ == 'param': if typ == '%param':
if not params: if not params:
pfield = nodes.field() pfield = nodes.field()
pfield += nodes.field_name('Parameters', 'Parameters') pfield += nodes.field_name('', _('Parameters'))
pfield += nodes.field_body() pfield += nodes.field_body()
params = nodes.bullet_list() params = nodes.bullet_list()
pfield[1] += params pfield[1] += params
@ -141,12 +145,12 @@ def handle_doc_fields(node):
dlitem = nodes.list_item() dlitem = nodes.list_item()
dlpar = nodes.paragraph() dlpar = nodes.paragraph()
dlpar += nodes.emphasis(obj, obj) dlpar += nodes.emphasis(obj, obj)
dlpar += nodes.Text(' -- ', ' -- ') dlpar += nodes.Text('', ' -- ')
dlpar += children dlpar += children
param_nodes[obj] = dlpar param_nodes[obj] = dlpar
dlitem += dlpar dlitem += dlpar
params += dlitem params += dlitem
elif typ == 'type': elif typ == '%type':
param_types[obj] = fbody.astext() param_types[obj] = fbody.astext()
else: else:
fieldname = typ + ' ' + obj fieldname = typ + ' ' + obj
@ -158,7 +162,7 @@ def handle_doc_fields(node):
except (KeyError, ValueError): except (KeyError, ValueError):
fnametext = fname.astext() fnametext = fname.astext()
try: try:
typ = doc_fields_without_arg[fnametext] typ = _(doc_fields_without_arg[fnametext])
except KeyError: except KeyError:
# at least capitalize the field name # at least capitalize the field name
typ = fnametext.capitalize() typ = fnametext.capitalize()
@ -299,7 +303,7 @@ def parse_c_signature(signode, sig, desctype):
raise ValueError('no match') raise ValueError('no match')
rettype, name, arglist, const = m.groups() rettype, name, arglist, const = m.groups()
signode += addnodes.desc_type("", "") signode += addnodes.desc_type('', '')
parse_c_type(signode[-1], rettype) parse_c_type(signode[-1], rettype)
try: try:
classname, funcname = name.split('::', 1) classname, funcname = name.split('::', 1)
@ -365,6 +369,7 @@ def parse_option_desc(signode, sig):
def desc_directive(desctype, arguments, options, content, lineno, def desc_directive(desctype, arguments, options, content, lineno,
content_offset, block_text, state, state_machine): content_offset, block_text, state, state_machine):
env = state.document.settings.env env = state.document.settings.env
inode = addnodes.index(entries=[])
node = addnodes.desc() node = addnodes.desc()
node['desctype'] = desctype node['desctype'] = desctype
@ -394,8 +399,10 @@ def desc_directive(desctype, arguments, options, content, lineno,
targetname = 'cmdoption-' + optname targetname = 'cmdoption-' + optname
signode['ids'].append(targetname) signode['ids'].append(targetname)
state.document.note_explicit_target(signode) state.document.note_explicit_target(signode)
env.note_index_entry('pair', 'command line option; %s' % sig, env.note_index_entry('pair', _('command line option; %s') % sig,
targetname, targetname) targetname, targetname)
inode['entries'].append(('pair', _('command line option; %s') % sig,
targetname, targetname))
env.note_reftarget('option', optname, targetname) env.note_reftarget('option', optname, targetname)
continue continue
elif desctype == 'describe': elif desctype == 'describe':
@ -417,7 +424,7 @@ def desc_directive(desctype, arguments, options, content, lineno,
signode['ids'].append(targetname) signode['ids'].append(targetname)
state.document.note_explicit_target(signode) state.document.note_explicit_target(signode)
if indextemplate: if indextemplate:
indexentry = indextemplate % (fullname,) indexentry = _(indextemplate) % (fullname,)
indextype = 'single' indextype = 'single'
colon = indexentry.find(':') colon = indexentry.find(':')
if colon != -1: if colon != -1:
@ -425,6 +432,8 @@ def desc_directive(desctype, arguments, options, content, lineno,
indexentry = indexentry[colon+1:].strip() indexentry = indexentry[colon+1:].strip()
env.note_index_entry(indextype, indexentry, env.note_index_entry(indextype, indexentry,
targetname, targetname) targetname, targetname)
inode['entries'].append((indextype, indexentry,
targetname, targetname))
env.note_reftarget(rolename, fullname, targetname) env.note_reftarget(rolename, fullname, targetname)
# don't use object indexing below # don't use object indexing below
continue continue
@ -446,9 +455,9 @@ def desc_directive(desctype, arguments, options, content, lineno,
env.note_descref(fullname, desctype, lineno) env.note_descref(fullname, desctype, lineno)
names.append(name) names.append(name)
env.note_index_entry('single', indextext = desc_index_text(desctype, module, name)
desc_index_text(desctype, module, name), env.note_index_entry('single', indextext, fullname, fullname)
fullname, fullname) inode['entries'].append(('single', indextext, fullname, fullname))
subnode = addnodes.desc_content() subnode = addnodes.desc_content()
# needed for automatic qualification of members # needed for automatic qualification of members
@ -469,7 +478,7 @@ def desc_directive(desctype, arguments, options, content, lineno,
env.currclass = None env.currclass = None
env.currdesc = None env.currdesc = None
node.append(subnode) node.append(subnode)
return [node] return [inode, node]
desc_directive.content = 1 desc_directive.content = 1
desc_directive.arguments = (1, 0, 1) desc_directive.arguments = (1, 0, 1)
@ -501,13 +510,17 @@ desctypes = [
for _name in desctypes: for _name in desctypes:
directives.register_directive(_name, desc_directive) directives.register_directive(_name, desc_directive)
_ = lambda x: x
# Generic cross-reference types; they can be registered in the application; # Generic cross-reference types; they can be registered in the application;
# the directives are either desc_directive or target_directive # the directives are either desc_directive or target_directive
additional_xref_types = { additional_xref_types = {
# directive name: (role name, index text, function to parse the desc node) # directive name: (role name, index text, function to parse the desc node)
'envvar': ('envvar', 'environment variable; %s', None), 'envvar': ('envvar', _('environment variable; %s'), None),
} }
del _
# ------ target -------------------------------------------------------------------- # ------ target --------------------------------------------------------------------
@ -521,6 +534,7 @@ def target_directive(targettype, arguments, options, content, lineno,
targetname = '%s-%s' % (rolename, fullname) targetname = '%s-%s' % (rolename, fullname)
node = nodes.target('', '', ids=[targetname]) node = nodes.target('', '', ids=[targetname])
state.document.note_explicit_target(node) state.document.note_explicit_target(node)
ret = [node]
if indextemplate: if indextemplate:
indexentry = indextemplate % (fullname,) indexentry = indextemplate % (fullname,)
indextype = 'single' indextype = 'single'
@ -529,8 +543,10 @@ def target_directive(targettype, arguments, options, content, lineno,
indextype = indexentry[:colon].strip() indextype = indexentry[:colon].strip()
indexentry = indexentry[colon+1:].strip() indexentry = indexentry[colon+1:].strip()
env.note_index_entry(indextype, indexentry, targetname, targetname) env.note_index_entry(indextype, indexentry, targetname, targetname)
inode = addnodes.index(entries=[(indextype, indexentry, targetname, targetname)])
ret.insert(0, inode)
env.note_reftarget(rolename, fullname, targetname) env.note_reftarget(rolename, fullname, targetname)
return [node] return ret
target_directive.content = 0 target_directive.content = 0
target_directive.arguments = (1, 0, 1) target_directive.arguments = (1, 0, 1)

View File

@ -16,6 +16,7 @@ from docutils.parsers.rst import directives
from sphinx import addnodes from sphinx import addnodes
from sphinx.util import patfilter from sphinx.util import patfilter
from sphinx.roles import caption_ref_re from sphinx.roles import caption_ref_re
from sphinx.locale import pairindextypes
from sphinx.util.compat import make_admonition from sphinx.util.compat import make_admonition
@ -98,13 +99,16 @@ def module_directive(name, arguments, options, content, lineno,
if 'platform' in options: if 'platform' in options:
modulenode['platform'] = options['platform'] modulenode['platform'] = options['platform']
node = nodes.paragraph() node = nodes.paragraph()
node += nodes.emphasis('Platforms: ', 'Platforms: ') node += nodes.emphasis('', _('Platforms: '))
node += nodes.Text(options['platform'], options['platform']) node += nodes.Text(options['platform'], options['platform'])
ret.append(node) ret.append(node)
# the synopsis isn't printed; in fact, it is only used in the modindex currently # the synopsis isn't printed; in fact, it is only used in the modindex currently
if not noindex: if not noindex:
env.note_index_entry('single', '%s (module)' % modname, indextext = _('%s (module)') % modname
'module-' + modname, modname) env.note_index_entry('single', indextext, 'module-' + modname, modname)
inode = addnodes.index(entries=[('single', indextext,
'module-' + modname, modname)])
ret.insert(0, inode)
return ret return ret
module_directive.arguments = (1, 0, 0) module_directive.arguments = (1, 0, 0)
@ -141,11 +145,11 @@ def author_directive(name, arguments, options, content, lineno,
emph = nodes.emphasis() emph = nodes.emphasis()
para += emph para += emph
if name == 'sectionauthor': if name == 'sectionauthor':
text = 'Section author: ' text = _('Section author: ')
elif name == 'moduleauthor': elif name == 'moduleauthor':
text = 'Module author: ' text = _('Module author: ')
else: else:
text = 'Author: ' text = _('Author: ')
emph += nodes.Text(text, text) emph += nodes.Text(text, text)
inodes, messages = state.inline_text(arguments[0], lineno) inodes, messages = state.inline_text(arguments[0], lineno)
emph.extend(inodes) emph.extend(inodes)
@ -158,9 +162,8 @@ directives.register_directive('moduleauthor', author_directive)
# ------ index markup -------------------------------------------------------------- # ------ index markup --------------------------------------------------------------
entrytypes = [ indextypes = [
'single', 'pair', 'triple', 'module', 'keyword', 'operator', 'single', 'pair', 'triple',
'object', 'exception', 'statement', 'builtin',
] ]
def index_directive(name, arguments, options, content, lineno, def index_directive(name, arguments, options, content, lineno,
@ -175,7 +178,15 @@ def index_directive(name, arguments, options, content, lineno,
indexnode['entries'] = ne = [] indexnode['entries'] = ne = []
for entry in arguments: for entry in arguments:
entry = entry.strip() entry = entry.strip()
for type in entrytypes: for type in pairindextypes:
if entry.startswith(type+':'):
value = entry[len(type)+1:].strip()
value = pairindextypes[type] + '; ' + value
env.note_index_entry(type, value, targetid, value)
ne.append((type, value, targetid, value))
break
else:
for type in indextypes:
if entry.startswith(type+':'): if entry.startswith(type+':'):
value = entry[len(type)+1:].strip() value = entry[len(type)+1:].strip()
env.note_index_entry(type, value, targetid, value) env.note_index_entry(type, value, targetid, value)
@ -184,7 +195,8 @@ def index_directive(name, arguments, options, content, lineno,
# shorthand notation for single entries # shorthand notation for single entries
else: else:
for value in entry.split(','): for value in entry.split(','):
env.note_index_entry('single', value.strip(), targetid, value.strip()) env.note_index_entry('single', value.strip(),
targetid, value.strip())
ne.append(('single', value.strip(), targetid, value.strip())) ne.append(('single', value.strip(), targetid, value.strip()))
return [indexnode, targetnode] return [indexnode, targetnode]
@ -223,7 +235,7 @@ directives.register_directive('versionchanged', version_directive)
def seealso_directive(name, arguments, options, content, lineno, def seealso_directive(name, arguments, options, content, lineno,
content_offset, block_text, state, state_machine): content_offset, block_text, state, state_machine):
rv = make_admonition( rv = make_admonition(
addnodes.seealso, name, ['See also'], options, content, addnodes.seealso, name, [_('See also')], options, content,
lineno, content_offset, block_text, state, state_machine) lineno, content_offset, block_text, state, state_machine)
return rv return rv
@ -292,7 +304,7 @@ directives.register_directive('productionlist', productionlist_directive)
def glossary_directive(name, arguments, options, content, lineno, def glossary_directive(name, arguments, options, content, lineno,
content_offset, block_text, state, state_machine): content_offset, block_text, state, state_machine):
"""Glossary with cross-reference targets for :dfn: roles.""" """Glossary with cross-reference targets for :term: roles."""
env = state.document.settings.env env = state.document.settings.env
node = addnodes.glossary() node = addnodes.glossary()
state.nested_parse(content, content_offset, node) state.nested_parse(content, content_offset, node)

View File

@ -1051,13 +1051,6 @@ class BuildEnvironment:
add_entry(first, second+' '+third) add_entry(first, second+' '+third)
add_entry(second, third+', '+first) add_entry(second, third+', '+first)
add_entry(third, first+' '+second) add_entry(third, first+' '+second)
elif type in ('module', 'keyword', 'operator', 'object',
'exception', 'statement'):
add_entry(string, type)
add_entry(type, string)
elif type == 'builtin':
add_entry(string, 'built-in function')
add_entry('built-in function', string)
else: else:
self.warn(fn, "unknown index entry type %r" % type) self.warn(fn, "unknown index entry type %r" % type)

View File

@ -152,7 +152,8 @@ def build_hhx(builder, outdir, outname):
f.write('<LI> ' + object_sitemap % (builder.config.html_short_title, f.write('<LI> ' + object_sitemap % (builder.config.html_short_title,
'index.html')) 'index.html'))
if builder.config.html_use_modindex: if builder.config.html_use_modindex:
f.write('<LI> ' + object_sitemap % ('Global Module Index', 'modindex.html')) f.write('<LI> ' + object_sitemap % (_('Global Module Index'),
'modindex.html'))
# the TOC # the TOC
tocdoc = builder.env.get_and_resolve_doctree(builder.config.master_doc, builder, tocdoc = builder.env.get_and_resolve_doctree(builder.config.master_doc, builder,
prune_toctrees=False) prune_toctrees=False)

View File

@ -15,6 +15,7 @@ import posixpath
from docutils import nodes from docutils import nodes
from docutils.writers.html4css1 import Writer, HTMLTranslator as BaseTranslator from docutils.writers.html4css1 import Writer, HTMLTranslator as BaseTranslator
from sphinx.locale import admonitionlabels, versionlabels
from sphinx.highlighting import PygmentsBridge from sphinx.highlighting import PygmentsBridge
from sphinx.util.smartypants import sphinx_smarty_pants from sphinx.util.smartypants import sphinx_smarty_pants
@ -38,12 +39,6 @@ class HTMLWriter(Writer):
setattr(self, attr, getattr(visitor, attr, None)) setattr(self, attr, getattr(visitor, attr, None))
version_text = {
'deprecated': 'Deprecated in version %s',
'versionchanged': 'Changed in version %s',
'versionadded': 'New in version %s',
}
class HTMLTranslator(BaseTranslator): class HTMLTranslator(BaseTranslator):
""" """
Our custom HTML translator. Our custom HTML translator.
@ -74,7 +69,8 @@ class HTMLTranslator(BaseTranslator):
def depart_desc_signature(self, node): def depart_desc_signature(self, node):
if node['ids'] and self.builder.add_definition_links: if node['ids'] and self.builder.add_definition_links:
self.body.append(u'<a class="headerlink" href="#%s" ' % node['ids'][0] + self.body.append(u'<a class="headerlink" href="#%s" ' % node['ids'][0] +
u'title="Permalink to this definition">\u00B6</a>') u'title="%s">\u00B6</a>' %
_('Permalink to this definition'))
self.body.append('</dt>\n') self.body.append('</dt>\n')
def visit_desc_addname(self, node): def visit_desc_addname(self, node):
@ -131,7 +127,7 @@ class HTMLTranslator(BaseTranslator):
def visit_versionmodified(self, node): def visit_versionmodified(self, node):
self.body.append(self.starttag(node, 'p')) self.body.append(self.starttag(node, 'p'))
text = version_text[node['type']] % node['version'] text = versionlabels[node['type']] % node['version']
if len(node): if len(node):
text += ': ' text += ': '
else: else:
@ -160,7 +156,7 @@ class HTMLTranslator(BaseTranslator):
self.body.append(self.starttag( self.body.append(self.starttag(
node, 'div', CLASS=('admonition ' + name))) node, 'div', CLASS=('admonition ' + name)))
if name and name != 'seealso': if name and name != 'seealso':
node.insert(0, nodes.title(name, self.language.labels[name])) node.insert(0, nodes.title(name, admonitionlabels[name]))
self.set_first_last(node) self.set_first_last(node)
def visit_seealso(self, node): def visit_seealso(self, node):
@ -379,11 +375,12 @@ class HTMLTranslator(BaseTranslator):
aname = node.parent['ids'][0] aname = node.parent['ids'][0]
# add permalink anchor # add permalink anchor
self.body.append(u'<a class="headerlink" href="#%s" ' % aname + self.body.append(u'<a class="headerlink" href="#%s" ' % aname +
u'title="Permalink to this headline">\u00B6</a>') u'title="%s">\u00B6</a>' %
_('Permalink to this headline'))
BaseTranslator.depart_title(self, node) BaseTranslator.depart_title(self, node)
def unknown_visit(self, node): def unknown_visit(self, node):
raise NotImplementedError("Unknown node: " + node.__class__.__name__) raise NotImplementedError('Unknown node: ' + node.__class__.__name__)
class SmartyPantsHTMLTranslator(HTMLTranslator): class SmartyPantsHTMLTranslator(HTMLTranslator):

View File

@ -18,24 +18,35 @@ import time
from os import path from os import path
from docutils import nodes, writers from docutils import nodes, writers
from docutils.writers.latex2e import Babel
from sphinx import addnodes from sphinx import addnodes
from sphinx import highlighting from sphinx import highlighting
from sphinx.locale import admonitionlabels, versionlabels
from sphinx.util.smartypants import educateQuotesLatex from sphinx.util.smartypants import educateQuotesLatex
HEADER = r'''%% Generated by Sphinx. HEADER = r'''%% Generated by Sphinx.
\documentclass[%(papersize)s,%(pointsize)s]{%(docclass)s} \documentclass[%(papersize)s,%(pointsize)s%(classoptions)s]{%(docclass)s}
\usepackage[utf8]{inputenc} \usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} \usepackage[T1]{fontenc}
\usepackage{babel}
\title{%(title)s} \title{%(title)s}
\date{%(date)s} \date{%(date)s}
\release{%(release)s} \release{%(release)s}
\author{%(author)s} \author{%(author)s}
\newcommand{\sphinxlogo}{%(logo)s} \newcommand{\sphinxlogo}{%(logo)s}
\renewcommand{\releasename}{%(releasename)s}
%(preamble)s %(preamble)s
\makeindex \makeindex
''' '''
BEGIN_DOC = r'''
\begin{document}
\shorthandoff{"}
\maketitle
\tableofcontents
'''
FOOTER = r''' FOOTER = r'''
\printindex \printindex
\end{document} \end{document}
@ -121,9 +132,14 @@ class LaTeXTranslator(nodes.NodeVisitor):
# if empty, the title is set to the first section title # if empty, the title is set to the first section title
'title': document.settings.title, 'title': document.settings.title,
'release': builder.config.release, 'release': builder.config.release,
'releasename': _('Release'),
'logo': logo, 'logo': logo,
'date': date, 'date': date,
'classoptions': '',
} }
if builder.config.language:
babel = Babel(builder.config.language)
self.options['classoptions'] += ',' + babel.get_language()
self.highlighter = highlighting.PygmentsBridge( self.highlighter = highlighting.PygmentsBridge(
'latex', builder.config.pygments_style) 'latex', builder.config.pygments_style)
self.context = [] self.context = []
@ -159,15 +175,15 @@ class LaTeXTranslator(nodes.NodeVisitor):
'\n\n' + \ '\n\n' + \
u''.join(self.body) + \ u''.join(self.body) + \
(self.options['modindex'] and (self.options['modindex'] and
'\\renewcommand{\\indexname}{Module Index}' ('\\renewcommand{\\indexname}{%s}' % _('Module index') +
'\\printmodindex' '\\printmodindex' +
'\\renewcommand{\\indexname}{Index}\n' or '') + \ '\\renewcommand{\\indexname}{%s}\n' % _('Index')) or '') + \
(FOOTER % self.options) (FOOTER % self.options)
def visit_document(self, node): def visit_document(self, node):
if self.first_document == 1: if self.first_document == 1:
# the first document is all the regular content ... # the first document is all the regular content ...
self.body.append('\\begin{document}\n\\maketitle\n\\tableofcontents\n') self.body.append(BEGIN_DOC)
self.first_document = 0 self.first_document = 0
elif self.first_document == 0: elif self.first_document == 0:
# ... and all others are the appendices # ... and all others are the appendices
@ -417,9 +433,9 @@ class LaTeXTranslator(nodes.NodeVisitor):
pass pass
def visit_seealso(self, node): def visit_seealso(self, node):
self.body.append("\n\n\\begin{seealso}\n") self.body.append("\n\n\\strong{%s:}\n\n" % admonitionlabels['seealso'])
def depart_seealso(self, node): def depart_seealso(self, node):
self.body.append("\n\\end{seealso}\n") self.body.append("\n\n")
def visit_rubric(self, node): def visit_rubric(self, node):
if len(node.children) == 1 and node.children[0].astext() == 'Footnotes': if len(node.children) == 1 and node.children[0].astext() == 'Footnotes':
@ -715,7 +731,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
def _make_visit_admonition(name): def _make_visit_admonition(name):
def visit_admonition(self, node): def visit_admonition(self, node):
self.body.append('\n\\begin{notice}[%s]' % name) self.body.append('\n\\begin{notice}{%s}{%s:}' %
(name, admonitionlabels[name]))
return visit_admonition return visit_admonition
def _depart_named_admonition(self, node): def _depart_named_admonition(self, node):
self.body.append('\\end{notice}\n') self.body.append('\\end{notice}\n')
@ -740,19 +757,14 @@ class LaTeXTranslator(nodes.NodeVisitor):
depart_warning = _depart_named_admonition depart_warning = _depart_named_admonition
def visit_versionmodified(self, node): def visit_versionmodified(self, node):
self.body.append('\\%s' % node['type']) intro = versionlabels[node['type']] % node['version']
if node['type'] == 'deprecated': if node.children:
self.body.append('{%s}{' % node['version']) intro += ': '
self.context.append('}')
else: else:
if len(node): intro += '.'
self.body.append('[') self.body.append(intro)
self.context.append(']{%s}' % node['version'])
else:
self.body.append('{%s}' % node['version'])
self.context.append('')
def depart_versionmodified(self, node): def depart_versionmodified(self, node):
self.body.append(self.context.pop()) pass
def visit_target(self, node): def visit_target(self, node):
def add_target(id): def add_target(id):
@ -781,16 +793,6 @@ class LaTeXTranslator(nodes.NodeVisitor):
def depart_attribution(self, node): def depart_attribution(self, node):
self.body.append('\n\\end{flushright}\n') self.body.append('\n\\end{flushright}\n')
indextype_map = {
'module': 'refmodindex',
'keyword': 'kwindex',
'operator': 'opindex',
'object': 'obindex',
'exception': 'exindex',
'statement': 'stindex',
'builtin': 'bifuncindex',
}
def visit_index(self, node, scre=re.compile(r';\s*')): def visit_index(self, node, scre=re.compile(r';\s*')):
entries = node['entries'] entries = node['entries']
for type, string, tid, _ in entries: for type, string, tid, _ in entries:
@ -802,9 +804,6 @@ class LaTeXTranslator(nodes.NodeVisitor):
elif type == 'triple': elif type == 'triple':
parts = tuple(self.encode(x.strip()) for x in string.split(';', 2)) parts = tuple(self.encode(x.strip()) for x in string.split(';', 2))
self.body.append(r'\indexiii{%s}{%s}{%s}' % parts) self.body.append(r'\indexiii{%s}{%s}{%s}' % parts)
elif type in self.indextype_map:
self.body.append(r'\%s{%s}' % (self.indextype_map[type],
self.encode(string)))
else: else:
self.builder.warn('unknown index entry type %s found' % type) self.builder.warn('unknown index entry type %s found' % type)
raise nodes.SkipNode raise nodes.SkipNode

48
sphinx/locale/__init__.py Normal file
View File

@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-
"""
sphinx.locale
~~~~~~~~~~~~~
Locale utilities.
:copyright: 2008 by Georg Brandl.
:license: BSD.
"""
_ = lambda x: x
admonitionlabels = {
'attention': _('Attention'),
'caution': _('Caution'),
'danger': _('Danger'),
'error': _('Error'),
'hint': _('Hint'),
'important': _('Important'),
'note': _('Note'),
'seealso': _('See Also'),
'tip': _('Tip'),
'warning': _('Warning'),
}
versionlabels = {
'versionadded': _('New in version %s'),
'versionchanged': _('Changed in version %s'),
'deprecated': _('Deprecated since version %s'),
}
pairindextypes = {
'module': _('module'),
'keyword': _('keyword'),
'operator': _('operator'),
'object': _('object'),
'exception': _('exception'),
'statement': _('statement'),
'builtin': _('built-in function'),
}
del _
def init():
for dct in (admonitionlabels, versionlabels, pairindextypes):
for key in dct:
dct[key] = _(dct[key])

View File

@ -1,4 +1,4 @@
# Translations template for Sphinx. # Czech translations for Sphinx.
# Copyright (C) 2008 ORGANIZATION # Copyright (C) 2008 ORGANIZATION
# This file is distributed under the same license as the Sphinx project. # This file is distributed under the same license as the Sphinx project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2008. # FIRST AUTHOR <EMAIL@ADDRESS>, 2008.
@ -8,55 +8,317 @@ msgstr ""
"Project-Id-Version: Sphinx 0.5\n" "Project-Id-Version: Sphinx 0.5\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2008-08-08 12:39+0000\n" "POT-Creation-Date: 2008-08-08 12:39+0000\n"
"PO-Revision-Date: 2008-08-08 15:43+0100\n" "PO-Revision-Date: 2008-08-10 11:43+0000\n"
"Last-Translator: Pavel Kosina <pavel.kosina@gmail.com>\n" "Last-Translator: Pavel Kosina <pavel.kosina@gmail.com>\n"
"Language-Team: Pavel Kosina <pavel.kosina@gmail.com>\n" "Language-Team: Pavel Kosina <pavel.kosina@gmail.com>\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && "
"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n" "Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 0.9.3\n" "Generated-By: Babel 0.9.3\n"
"X-Poedit-Language: Czech\n"
"X-Poedit-Country: CZECH REPUBLIC\n"
#: sphinx/builder.py:390 #: sphinx/builder.py:391
#, python-format #, python-format
msgid "%b %d, %Y" msgid "%b %d, %Y"
msgstr "%d.%m.%Y" msgstr "%d.%m.%Y"
#: sphinx/builder.py:409 #: sphinx/builder.py:410 sphinx/templates/defindex.html:21
#: sphinx/templates/defindex.html:21
msgid "General Index" msgid "General Index"
msgstr "Generální index" msgstr "Generální index"
#: sphinx/builder.py:409 #: sphinx/builder.py:410
msgid "index" msgid "index"
msgstr "index" msgstr "index"
#: sphinx/builder.py:411 #: sphinx/builder.py:412 sphinx/htmlhelp.py:155
#: sphinx/templates/defindex.html:19 #: sphinx/templates/defindex.html:19 sphinx/templates/modindex.html:2
#: sphinx/templates/modindex.html:2
#: sphinx/templates/modindex.html:12 #: sphinx/templates/modindex.html:12
msgid "Global Module Index" msgid "Global Module Index"
msgstr "Index modulů" msgstr "Index modulů"
#: sphinx/builder.py:411 #: sphinx/builder.py:412
msgid "modules" msgid "modules"
msgstr "moduly" msgstr "moduly"
#: sphinx/builder.py:447 #: sphinx/builder.py:448
msgid "next" msgid "next"
msgstr "další" msgstr "další"
#: sphinx/builder.py:454 #: sphinx/builder.py:455
msgid "previous" msgid "previous"
msgstr "předchozí" msgstr "předchozí"
#: sphinx/environment.py:108 #: sphinx/builder.py:1089
#: sphinx/latexwriter.py:110 msgid "Builtins"
msgstr ""
#: sphinx/builder.py:1091
#, fuzzy
msgid "Module level"
msgstr "moduly"
#: sphinx/environment.py:108 sphinx/latexwriter.py:114
#, python-format #, python-format
msgid "%B %d, %Y" msgid "%B %d, %Y"
msgstr "%d.%m.%Y" msgstr "%d.%m.%Y"
#: sphinx/htmlwriter.py:73
msgid "Permalink to this definition"
msgstr ""
#: sphinx/htmlwriter.py:379
msgid "Permalink to this headline"
msgstr ""
#: sphinx/latexwriter.py:128
msgid "Release"
msgstr ""
#: sphinx/latexwriter.py:171
msgid "Module index"
msgstr "Index modulů"
#: sphinx/latexwriter.py:173 sphinx/templates/genindex-single.html:2
#: sphinx/templates/genindex-split.html:2
#: sphinx/templates/genindex-split.html:5 sphinx/templates/genindex.html:2
#: sphinx/templates/genindex.html:5 sphinx/templates/genindex.html:48
msgid "Index"
msgstr "Index"
#: sphinx/roles.py:52 sphinx/roles.py:55 sphinx/directives/desc.py:519
#, python-format
msgid "environment variable; %s"
msgstr ""
#: sphinx/roles.py:61 sphinx/roles.py:64
#, python-format
msgid "Python Enhancement Proposals!PEP %s"
msgstr ""
#: sphinx/textwriter.py:151
#, python-format
msgid "Platform: %s"
msgstr ""
#: sphinx/textwriter.py:353
msgid "[image]"
msgstr ""
#: sphinx/directives/desc.py:26
#, python-format
msgid "%s() (built-in function)"
msgstr ""
#: sphinx/directives/desc.py:27 sphinx/directives/desc.py:41
#: sphinx/directives/desc.py:53
#, python-format
msgid "%s() (in module %s)"
msgstr ""
#: sphinx/directives/desc.py:30
#, python-format
msgid "%s (built-in variable)"
msgstr ""
#: sphinx/directives/desc.py:31 sphinx/directives/desc.py:65
#, python-format
msgid "%s (in module %s)"
msgstr ""
#: sphinx/directives/desc.py:33
#, python-format
msgid "%s (class in %s)"
msgstr ""
#: sphinx/directives/desc.py:45
#, python-format
msgid "%s() (%s.%s method)"
msgstr ""
#: sphinx/directives/desc.py:47
#, python-format
msgid "%s() (%s method)"
msgstr ""
#: sphinx/directives/desc.py:57
#, python-format
msgid "%s() (%s.%s static method)"
msgstr ""
#: sphinx/directives/desc.py:59
#, python-format
msgid "%s() (%s static method)"
msgstr ""
#: sphinx/directives/desc.py:69
#, python-format
msgid "%s (%s.%s attribute)"
msgstr ""
#: sphinx/directives/desc.py:71
#, python-format
msgid "%s (%s attribute)"
msgstr ""
#: sphinx/directives/desc.py:73
#, python-format
msgid "%s (C function)"
msgstr ""
#: sphinx/directives/desc.py:75
#, python-format
msgid "%s (C member)"
msgstr ""
#: sphinx/directives/desc.py:77
#, python-format
msgid "%s (C macro)"
msgstr ""
#: sphinx/directives/desc.py:79
#, python-format
msgid "%s (C type)"
msgstr ""
#: sphinx/directives/desc.py:81
#, python-format
msgid "%s (C variable)"
msgstr ""
#: sphinx/directives/desc.py:99
msgid "Raises"
msgstr ""
#: sphinx/directives/desc.py:103
msgid "Variable"
msgstr ""
#: sphinx/directives/desc.py:106
msgid "Returns"
msgstr ""
#: sphinx/directives/desc.py:113
msgid "Return type"
msgstr ""
#: sphinx/directives/desc.py:140
msgid "Parameters"
msgstr ""
#: sphinx/directives/desc.py:402 sphinx/directives/desc.py:404
#, python-format
msgid "command line option; %s"
msgstr ""
#: sphinx/directives/other.py:102
msgid "Platforms: "
msgstr ""
#: sphinx/directives/other.py:107
#, python-format
msgid "%s (module)"
msgstr "%s (moduly)"
#: sphinx/directives/other.py:148
msgid "Section author: "
msgstr ""
#: sphinx/directives/other.py:150
msgid "Module author: "
msgstr ""
#: sphinx/directives/other.py:152
msgid "Author: "
msgstr ""
#: sphinx/directives/other.py:238
msgid "See also"
msgstr ""
#: sphinx/locale/__init__.py:15
msgid "Attention"
msgstr ""
#: sphinx/locale/__init__.py:16
msgid "Caution"
msgstr ""
#: sphinx/locale/__init__.py:17
msgid "Danger"
msgstr ""
#: sphinx/locale/__init__.py:18
msgid "Error"
msgstr ""
#: sphinx/locale/__init__.py:19
msgid "Hint"
msgstr ""
#: sphinx/locale/__init__.py:20
msgid "Important"
msgstr ""
#: sphinx/locale/__init__.py:21
msgid "Note"
msgstr ""
#: sphinx/locale/__init__.py:22
msgid "See Also"
msgstr ""
#: sphinx/locale/__init__.py:23
msgid "Tip"
msgstr ""
#: sphinx/locale/__init__.py:24
msgid "Warning"
msgstr ""
#: sphinx/locale/__init__.py:28
#, python-format
msgid "New in version %s"
msgstr ""
#: sphinx/locale/__init__.py:29
#, python-format
msgid "Changed in version %s"
msgstr ""
#: sphinx/locale/__init__.py:30
#, python-format
msgid "Deprecated since version %s"
msgstr ""
#: sphinx/locale/__init__.py:34
msgid "module"
msgstr "moduly"
#: sphinx/locale/__init__.py:35
msgid "keyword"
msgstr ""
#: sphinx/locale/__init__.py:36
msgid "operator"
msgstr ""
#: sphinx/locale/__init__.py:37
msgid "object"
msgstr ""
#: sphinx/locale/__init__.py:38
msgid "exception"
msgstr ""
#: sphinx/locale/__init__.py:39
msgid "statement"
msgstr ""
#: sphinx/locale/__init__.py:40
msgid "built-in function"
msgstr ""
#: sphinx/templates/defindex.html:2 #: sphinx/templates/defindex.html:2
msgid "Overview" msgid "Overview"
msgstr "Přehled" msgstr "Přehled"
@ -89,28 +351,14 @@ msgstr "rychlý přístup ke všem modulům"
msgid "all functions, classes, terms" msgid "all functions, classes, terms"
msgstr "všechny funkce, třídy, termíny" msgstr "všechny funkce, třídy, termíny"
#: sphinx/templates/genindex-single.html:2
#: sphinx/templates/genindex-split.html:2
#: sphinx/templates/genindex-split.html:5
#: sphinx/templates/genindex.html:2
#: sphinx/templates/genindex.html:5
#: sphinx/templates/genindex.html:48
msgid "Index"
msgstr "Index"
#: sphinx/templates/genindex-single.html:5 #: sphinx/templates/genindex-single.html:5
#, python-format #, python-format
msgid "Index &ndash; %(key)s" msgid "Index &ndash; %(key)s"
msgstr "Index &ndash; %(key)s" msgstr "Index &ndash; %(key)s"
#: sphinx/templates/genindex-single.html:14
msgid "Link"
msgstr "Odkaz"
#: sphinx/templates/genindex-single.html:44 #: sphinx/templates/genindex-single.html:44
#: sphinx/templates/genindex-split.html:14 #: sphinx/templates/genindex-split.html:14
#: sphinx/templates/genindex-split.html:27 #: sphinx/templates/genindex-split.html:27 sphinx/templates/genindex.html:54
#: sphinx/templates/genindex.html:54
msgid "Full index on one page" msgid "Full index on one page"
msgstr "Plný index na jedné stránce" msgstr "Plný index na jedné stránce"
@ -154,8 +402,7 @@ msgstr "Tato stránka"
msgid "Suggest Change" msgid "Suggest Change"
msgstr "Návrh změnu" msgstr "Návrh změnu"
#: sphinx/templates/layout.html:60 #: sphinx/templates/layout.html:60 sphinx/templates/layout.html:62
#: sphinx/templates/layout.html:62
msgid "Show Source" msgid "Show Source"
msgstr "Ukázat zdroj" msgstr "Ukázat zdroj"
@ -192,8 +439,7 @@ msgstr "Celkový obsah"
msgid "Global index" msgid "Global index"
msgstr "Celkový index" msgstr "Celkový index"
#: sphinx/templates/layout.html:131 #: sphinx/templates/layout.html:131 sphinx/templates/search.html:2
#: sphinx/templates/search.html:2
#: sphinx/templates/search.html:5 #: sphinx/templates/search.html:5
msgid "Search" msgid "Search"
msgstr "Hledání" msgstr "Hledání"
@ -219,8 +465,12 @@ msgstr "Naposledy aktualizováno dne %(last_updated)s."
#: sphinx/templates/layout.html:186 #: sphinx/templates/layout.html:186
#, python-format #, python-format
msgid "Created using <a href=\"http://sphinx.pocoo.org/\">Sphinx</a> %(sphinx_version)s." msgid ""
msgstr "vytvořeno pomocí <a href=\"http://sphinx.pocoo.org/\">Sphinx</a> %(sphinx_version)s." "Created using <a href=\"http://sphinx.pocoo.org/\">Sphinx</a> "
"%(sphinx_version)s."
msgstr ""
"vytvořeno pomocí <a href=\"http://sphinx.pocoo.org/\">Sphinx</a> "
"%(sphinx_version)s."
#: sphinx/templates/modindex.html:14 #: sphinx/templates/modindex.html:14
msgid "Most popular modules:" msgid "Most popular modules:"
@ -240,8 +490,14 @@ msgid "Search %(docstitle)s"
msgstr "Prohledat %(docstitle)s" msgstr "Prohledat %(docstitle)s"
#: sphinx/templates/page.html:8 #: sphinx/templates/page.html:8
msgid "<strong>Note:</strong> You requested an out-of-date URL from this server. We've tried to redirect you to the new location of this page, but it may not be the right one." msgid ""
msgstr "<strong>Note:</strong> You requested an out-of-date URL from this server. We've tried to redirect you to the new location of this page, but it may not be the right one." "<strong>Note:</strong> You requested an out-of-date URL from this server."
" We've tried to redirect you to the new location of this page, but it may"
" not be the right one."
msgstr ""
"<strong>Note:</strong> You requested an out-of-date URL from this server."
" We've tried to redirect you to the new location of this page, but it may"
" not be the right one."
#: sphinx/templates/search.html:7 #: sphinx/templates/search.html:7
msgid "" msgid ""

View File

@ -1,14 +1,13 @@
# German translations for Sphinx. # German translations for Sphinx.
# Copyright (C) 2008 ORGANIZATION # Copyright (C) 2008 Translators.
# This file is distributed under the same license as the PROJECT project. # This file is distributed under the same license as the Sphinx project.
# <EMAIL@ADDRESS>, 2008.
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PROJECT VERSION\n" "Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2008-08-07 21:40+0200\n" "POT-Creation-Date: 2008-08-07 21:40+0200\n"
"PO-Revision-Date: 2008-08-08 12:40+0000\n" "PO-Revision-Date: 2008-08-10 11:43+0000\n"
"Last-Translator: Horst Gutmann <zerok@zerokspot.com>\n" "Last-Translator: Horst Gutmann <zerok@zerokspot.com>\n"
"Language-Team: de <LL@li.org>\n" "Language-Team: de <LL@li.org>\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n" "Plural-Forms: nplurals=2; plural=(n != 1)\n"
@ -17,40 +16,305 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 0.9.3\n" "Generated-By: Babel 0.9.3\n"
#: sphinx/builder.py:390 #: sphinx/builder.py:391
#, fuzzy, python-format #, python-format
msgid "%b %d, %Y" msgid "%b %d, %Y"
msgstr "%d.%b.%Y" msgstr "%d. %m. %Y"
#: sphinx/builder.py:409 sphinx/templates/defindex.html:21 #: sphinx/builder.py:410 sphinx/templates/defindex.html:21
msgid "General Index" msgid "General Index"
msgstr "Allgemeiner Index" msgstr "Allgemeiner Index"
#: sphinx/builder.py:409 #: sphinx/builder.py:410
msgid "index" msgid "index"
msgstr "Index" msgstr "Index"
#: sphinx/builder.py:411 sphinx/templates/defindex.html:19 #: sphinx/builder.py:412 sphinx/htmlhelp.py:155
#: sphinx/templates/modindex.html:2 sphinx/templates/modindex.html:12 #: sphinx/templates/defindex.html:19 sphinx/templates/modindex.html:2
#: sphinx/templates/modindex.html:12
msgid "Global Module Index" msgid "Global Module Index"
msgstr "Globaler Modulindex" msgstr "Globaler Modulindex"
#: sphinx/builder.py:411 #: sphinx/builder.py:412
msgid "modules" msgid "modules"
msgstr "Module" msgstr "Module"
#: sphinx/builder.py:447 #: sphinx/builder.py:448
msgid "next" msgid "next"
msgstr "weiter" msgstr "weiter"
#: sphinx/builder.py:454 #: sphinx/builder.py:455
msgid "previous" msgid "previous"
msgstr "zurück" msgstr "zurück"
#: sphinx/environment.py:108 sphinx/latexwriter.py:110 #: sphinx/builder.py:1089
msgid "Builtins"
msgstr "Builtins"
#: sphinx/builder.py:1091
msgid "Module level"
msgstr "Modulebene"
#: sphinx/environment.py:108 sphinx/latexwriter.py:114
#, python-format #, python-format
msgid "%B %d, %Y" msgid "%B %d, %Y"
msgstr "%d.%b.%Y" msgstr "%d. %m. %Y"
#: sphinx/htmlwriter.py:73
msgid "Permalink to this definition"
msgstr "Permalink zu dieser Definition"
#: sphinx/htmlwriter.py:379
msgid "Permalink to this headline"
msgstr "Permalink zu dieser Überschrift"
#: sphinx/latexwriter.py:128
msgid "Release"
msgstr "Release"
#: sphinx/latexwriter.py:171
msgid "Module index"
msgstr "Modulindex"
#: sphinx/latexwriter.py:173 sphinx/templates/genindex-single.html:2
#: sphinx/templates/genindex-split.html:2
#: sphinx/templates/genindex-split.html:5 sphinx/templates/genindex.html:2
#: sphinx/templates/genindex.html:5 sphinx/templates/genindex.html:48
msgid "Index"
msgstr "Stichwortverzeichnis"
#: sphinx/roles.py:52 sphinx/roles.py:55 sphinx/directives/desc.py:519
#, python-format
msgid "environment variable; %s"
msgstr "Umgebungsvariable; %s"
#: sphinx/roles.py:61 sphinx/roles.py:64
#, python-format
msgid "Python Enhancement Proposals!PEP %s"
msgstr "Python Enhancement Proposals!PEP %s"
#: sphinx/textwriter.py:151
#, python-format
msgid "Platform: %s"
msgstr "Plattform: %s"
#: sphinx/textwriter.py:353
msgid "[image]"
msgstr "[Bild]"
#: sphinx/directives/desc.py:26
#, python-format
msgid "%s() (built-in function)"
msgstr "%s() (eingebaute Funktion)"
#: sphinx/directives/desc.py:27 sphinx/directives/desc.py:41
#: sphinx/directives/desc.py:53
#, python-format
msgid "%s() (in module %s)"
msgstr "%s() (in Modul %s)"
#: sphinx/directives/desc.py:30
#, python-format
msgid "%s (built-in variable)"
msgstr "%s (eingebaute Variable)"
#: sphinx/directives/desc.py:31 sphinx/directives/desc.py:65
#, python-format
msgid "%s (in module %s)"
msgstr "%s (in Modul %s)"
#: sphinx/directives/desc.py:33
#, python-format
msgid "%s (class in %s)"
msgstr "%s (Klasse in %s)"
#: sphinx/directives/desc.py:45
#, python-format
msgid "%s() (%s.%s method)"
msgstr "%s() (Methode von %s.%s)"
#: sphinx/directives/desc.py:47
#, python-format
msgid "%s() (%s method)"
msgstr "%s() (Methode von %s)"
#: sphinx/directives/desc.py:57
#, python-format
msgid "%s() (%s.%s static method)"
msgstr "%s() (statische Methode von %s.%s)"
#: sphinx/directives/desc.py:59
#, python-format
msgid "%s() (%s static method)"
msgstr "%s() (statische Methode von %s)"
#: sphinx/directives/desc.py:69
#, python-format
msgid "%s (%s.%s attribute)"
msgstr "%s (Attribut von %s.%s)"
#: sphinx/directives/desc.py:71
#, python-format
msgid "%s (%s attribute)"
msgstr "%s (Attribut von %s)"
#: sphinx/directives/desc.py:73
#, python-format
msgid "%s (C function)"
msgstr "%s (C-Funktion)"
#: sphinx/directives/desc.py:75
#, python-format
msgid "%s (C member)"
msgstr "%s (C-Member)"
#: sphinx/directives/desc.py:77
#, python-format
msgid "%s (C macro)"
msgstr "%s (C-Makro)"
#: sphinx/directives/desc.py:79
#, python-format
msgid "%s (C type)"
msgstr "%s (C-Typ)"
#: sphinx/directives/desc.py:81
#, python-format
msgid "%s (C variable)"
msgstr "%s (C-Variable)"
#: sphinx/directives/desc.py:99
msgid "Raises"
msgstr "Verursacht:"
#: sphinx/directives/desc.py:103
msgid "Variable"
msgstr "Variable"
#: sphinx/directives/desc.py:106
msgid "Returns"
msgstr "Rückgabe"
#: sphinx/directives/desc.py:113
msgid "Return type"
msgstr "Rückgabetyp"
#: sphinx/directives/desc.py:140
msgid "Parameters"
msgstr "Parameter"
#: sphinx/directives/desc.py:402 sphinx/directives/desc.py:404
#, python-format
msgid "command line option; %s"
msgstr "Kommandozeilenoption; %s"
#: sphinx/directives/other.py:102
msgid "Platforms: "
msgstr "Plattformen: "
#: sphinx/directives/other.py:107
#, python-format
msgid "%s (module)"
msgstr "%s (Modul)"
#: sphinx/directives/other.py:148
msgid "Section author: "
msgstr "Autor des Abschnitts: "
#: sphinx/directives/other.py:150
msgid "Module author: "
msgstr "Autor des Moduls: "
#: sphinx/directives/other.py:152
msgid "Author: "
msgstr "Autor: "
#: sphinx/directives/other.py:238
msgid "See also"
msgstr "Siehe auch"
#: sphinx/locale/__init__.py:15
msgid "Attention"
msgstr "Achtung"
#: sphinx/locale/__init__.py:16
msgid "Caution"
msgstr "Vorsicht"
#: sphinx/locale/__init__.py:17
msgid "Danger"
msgstr "Gefahr"
#: sphinx/locale/__init__.py:18
msgid "Error"
msgstr "Fehler"
#: sphinx/locale/__init__.py:19
msgid "Hint"
msgstr "Hinweis"
#: sphinx/locale/__init__.py:20
msgid "Important"
msgstr "Wichtig"
#: sphinx/locale/__init__.py:21
msgid "Note"
msgstr "Bemerkung"
#: sphinx/locale/__init__.py:22
msgid "See Also"
msgstr "Siehe auch"
#: sphinx/locale/__init__.py:23
msgid "Tip"
msgstr "Tipp"
#: sphinx/locale/__init__.py:24
msgid "Warning"
msgstr "Warnung"
#: sphinx/locale/__init__.py:28
#, python-format
msgid "New in version %s"
msgstr "Neu in Version %s"
#: sphinx/locale/__init__.py:29
#, python-format
msgid "Changed in version %s"
msgstr "Geändert in Version %s"
#: sphinx/locale/__init__.py:30
#, python-format
msgid "Deprecated since version %s"
msgstr "Veraltet ab Version %s"
#: sphinx/locale/__init__.py:34
msgid "module"
msgstr "Module"
#: sphinx/locale/__init__.py:35
msgid "keyword"
msgstr "Schlüsselwort"
#: sphinx/locale/__init__.py:36
msgid "operator"
msgstr "Operator"
#: sphinx/locale/__init__.py:37
msgid "object"
msgstr "Objekt"
#: sphinx/locale/__init__.py:38
msgid "exception"
msgstr "Exception"
#: sphinx/locale/__init__.py:39
msgid "statement"
msgstr "Statement"
#: sphinx/locale/__init__.py:40
msgid "built-in function"
msgstr "eingebaute Funktion"
#: sphinx/templates/defindex.html:2 #: sphinx/templates/defindex.html:2
msgid "Overview" msgid "Overview"
@ -84,22 +348,11 @@ msgstr "Schneller Zugriff auf alle Module"
msgid "all functions, classes, terms" msgid "all functions, classes, terms"
msgstr "Alle Funktionen, Klassen, Begriffe" msgstr "Alle Funktionen, Klassen, Begriffe"
#: sphinx/templates/genindex-single.html:2
#: sphinx/templates/genindex-split.html:2
#: sphinx/templates/genindex-split.html:5 sphinx/templates/genindex.html:2
#: sphinx/templates/genindex.html:5 sphinx/templates/genindex.html:48
msgid "Index"
msgstr "Stichwortverzeichnis"
#: sphinx/templates/genindex-single.html:5 #: sphinx/templates/genindex-single.html:5
#, python-format #, python-format
msgid "Index &ndash; %(key)s" msgid "Index &ndash; %(key)s"
msgstr "Stichwortverzeichnis &ndash; %(key)s" msgstr "Stichwortverzeichnis &ndash; %(key)s"
#: sphinx/templates/genindex-single.html:14
msgid "Link"
msgstr "Link"
#: sphinx/templates/genindex-single.html:44 #: sphinx/templates/genindex-single.html:44
#: sphinx/templates/genindex-split.html:14 #: sphinx/templates/genindex-split.html:14
#: sphinx/templates/genindex-split.html:27 sphinx/templates/genindex.html:54 #: sphinx/templates/genindex-split.html:27 sphinx/templates/genindex.html:54
@ -238,7 +491,10 @@ msgid ""
"<strong>Note:</strong> You requested an out-of-date URL from this server." "<strong>Note:</strong> You requested an out-of-date URL from this server."
" We've tried to redirect you to the new location of this page, but it may" " We've tried to redirect you to the new location of this page, but it may"
" not be the right one." " not be the right one."
msgstr "<strong>Anmerkung:</strong> Du hast eine nicht länger gültige URL von diesem Server angefragt. Wir haben versucht dich auf die neue Adresse dieser Seite umzuleiten, aber dies muss nicht die richtige Seite sein." msgstr ""
"<strong>Anmerkung:</strong> Du hast eine nicht länger gültige URL von "
"diesem Server angefragt. Wir haben versucht dich auf die neue Adresse "
"dieser Seite umzuleiten, aber dies muss nicht die richtige Seite sein."
#: sphinx/templates/search.html:7 #: sphinx/templates/search.html:7
msgid "" msgid ""
@ -246,7 +502,12 @@ msgid ""
" words into the box below and click \"search\". Note that the search\n" " words into the box below and click \"search\". Note that the search\n"
" function will automatically search for all of the words. Pages\n" " function will automatically search for all of the words. Pages\n"
" containing less words won't appear in the result list." " containing less words won't appear in the result list."
msgstr "Von hier aus kannst du die Dokumentation durchsuchen. Gib deine Suchbegriffe in das untenstehende Feld ein und klicke auf \"suchen\". Bitte beachte, dass die Suchfunktion automatisch nach all diesen Worten suchen wird. Seiten, die nicht alle Worte enthalten, werden nicht in der Ergebnisliste erscheinen." msgstr ""
"Von hier aus kannst du die Dokumentation durchsuchen. Gib deine "
"Suchbegriffe in das untenstehende Feld ein und klicke auf \"suchen\". "
"Bitte beachte, dass die Suchfunktion automatisch nach all diesen Worten "
"suchen wird. Seiten, die nicht alle Worte enthalten, werden nicht in der "
"Ergebnisliste erscheinen."
#: sphinx/templates/search.html:14 #: sphinx/templates/search.html:14
msgid "search" msgid "search"
@ -287,3 +548,4 @@ msgstr "C API-Änderungen"
#: sphinx/templates/changes/versionchanges.html:25 #: sphinx/templates/changes/versionchanges.html:25
msgid "Other changes" msgid "Other changes"
msgstr "Andere Änderungen" msgstr "Andere Änderungen"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Sphinx 0.5\n" "Project-Id-Version: Sphinx 0.5\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2008-08-08 12:39+0000\n" "POT-Creation-Date: 2008-08-10 11:43+0000\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"
@ -17,41 +17,306 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 0.9.3\n" "Generated-By: Babel 0.9.3\n"
#: sphinx/builder.py:390 #: sphinx/builder.py:391
#, python-format #, python-format
msgid "%b %d, %Y" msgid "%b %d, %Y"
msgstr "" msgstr ""
#: sphinx/builder.py:409 sphinx/templates/defindex.html:21 #: sphinx/builder.py:410 sphinx/templates/defindex.html:21
msgid "General Index" msgid "General Index"
msgstr "" msgstr ""
#: sphinx/builder.py:409 #: sphinx/builder.py:410
msgid "index" msgid "index"
msgstr "" msgstr ""
#: sphinx/builder.py:411 sphinx/templates/defindex.html:19 #: sphinx/builder.py:412 sphinx/htmlhelp.py:155
#: sphinx/templates/modindex.html:2 sphinx/templates/modindex.html:12 #: sphinx/templates/defindex.html:19 sphinx/templates/modindex.html:2
#: sphinx/templates/modindex.html:12
msgid "Global Module Index" msgid "Global Module Index"
msgstr "" msgstr ""
#: sphinx/builder.py:411 #: sphinx/builder.py:412
msgid "modules" msgid "modules"
msgstr "" msgstr ""
#: sphinx/builder.py:447 #: sphinx/builder.py:448
msgid "next" msgid "next"
msgstr "" msgstr ""
#: sphinx/builder.py:454 #: sphinx/builder.py:455
msgid "previous" msgid "previous"
msgstr "" msgstr ""
#: sphinx/environment.py:108 sphinx/latexwriter.py:110 #: sphinx/builder.py:1089
msgid "Builtins"
msgstr ""
#: sphinx/builder.py:1091
msgid "Module level"
msgstr ""
#: sphinx/environment.py:108 sphinx/latexwriter.py:114
#, python-format #, python-format
msgid "%B %d, %Y" msgid "%B %d, %Y"
msgstr "" msgstr ""
#: sphinx/htmlwriter.py:73
msgid "Permalink to this definition"
msgstr ""
#: sphinx/htmlwriter.py:379
msgid "Permalink to this headline"
msgstr ""
#: sphinx/latexwriter.py:128
msgid "Release"
msgstr ""
#: sphinx/latexwriter.py:171
msgid "Module index"
msgstr ""
#: sphinx/latexwriter.py:173 sphinx/templates/genindex-single.html:2
#: sphinx/templates/genindex-split.html:2
#: sphinx/templates/genindex-split.html:5 sphinx/templates/genindex.html:2
#: sphinx/templates/genindex.html:5 sphinx/templates/genindex.html:48
msgid "Index"
msgstr ""
#: sphinx/roles.py:52 sphinx/roles.py:55 sphinx/directives/desc.py:519
#, python-format
msgid "environment variable; %s"
msgstr ""
#: sphinx/roles.py:61 sphinx/roles.py:64
#, python-format
msgid "Python Enhancement Proposals!PEP %s"
msgstr ""
#: sphinx/textwriter.py:151
#, python-format
msgid "Platform: %s"
msgstr ""
#: sphinx/textwriter.py:353
msgid "[image]"
msgstr ""
#: sphinx/directives/desc.py:26
#, python-format
msgid "%s() (built-in function)"
msgstr ""
#: sphinx/directives/desc.py:27 sphinx/directives/desc.py:41
#: sphinx/directives/desc.py:53
#, python-format
msgid "%s() (in module %s)"
msgstr ""
#: sphinx/directives/desc.py:30
#, python-format
msgid "%s (built-in variable)"
msgstr ""
#: sphinx/directives/desc.py:31 sphinx/directives/desc.py:65
#, python-format
msgid "%s (in module %s)"
msgstr ""
#: sphinx/directives/desc.py:33
#, python-format
msgid "%s (class in %s)"
msgstr ""
#: sphinx/directives/desc.py:45
#, python-format
msgid "%s() (%s.%s method)"
msgstr ""
#: sphinx/directives/desc.py:47
#, python-format
msgid "%s() (%s method)"
msgstr ""
#: sphinx/directives/desc.py:57
#, python-format
msgid "%s() (%s.%s static method)"
msgstr ""
#: sphinx/directives/desc.py:59
#, python-format
msgid "%s() (%s static method)"
msgstr ""
#: sphinx/directives/desc.py:69
#, python-format
msgid "%s (%s.%s attribute)"
msgstr ""
#: sphinx/directives/desc.py:71
#, python-format
msgid "%s (%s attribute)"
msgstr ""
#: sphinx/directives/desc.py:73
#, python-format
msgid "%s (C function)"
msgstr ""
#: sphinx/directives/desc.py:75
#, python-format
msgid "%s (C member)"
msgstr ""
#: sphinx/directives/desc.py:77
#, python-format
msgid "%s (C macro)"
msgstr ""
#: sphinx/directives/desc.py:79
#, python-format
msgid "%s (C type)"
msgstr ""
#: sphinx/directives/desc.py:81
#, python-format
msgid "%s (C variable)"
msgstr ""
#: sphinx/directives/desc.py:99
msgid "Raises"
msgstr ""
#: sphinx/directives/desc.py:103
msgid "Variable"
msgstr ""
#: sphinx/directives/desc.py:106
msgid "Returns"
msgstr ""
#: sphinx/directives/desc.py:113
msgid "Return type"
msgstr ""
#: sphinx/directives/desc.py:140
msgid "Parameters"
msgstr ""
#: sphinx/directives/desc.py:402 sphinx/directives/desc.py:404
#, python-format
msgid "command line option; %s"
msgstr ""
#: sphinx/directives/other.py:102
msgid "Platforms: "
msgstr ""
#: sphinx/directives/other.py:107
#, python-format
msgid "%s (module)"
msgstr ""
#: sphinx/directives/other.py:148
msgid "Section author: "
msgstr ""
#: sphinx/directives/other.py:150
msgid "Module author: "
msgstr ""
#: sphinx/directives/other.py:152
msgid "Author: "
msgstr ""
#: sphinx/directives/other.py:238
msgid "See also"
msgstr ""
#: sphinx/locale/__init__.py:15
msgid "Attention"
msgstr ""
#: sphinx/locale/__init__.py:16
msgid "Caution"
msgstr ""
#: sphinx/locale/__init__.py:17
msgid "Danger"
msgstr ""
#: sphinx/locale/__init__.py:18
msgid "Error"
msgstr ""
#: sphinx/locale/__init__.py:19
msgid "Hint"
msgstr ""
#: sphinx/locale/__init__.py:20
msgid "Important"
msgstr ""
#: sphinx/locale/__init__.py:21
msgid "Note"
msgstr ""
#: sphinx/locale/__init__.py:22
msgid "See Also"
msgstr ""
#: sphinx/locale/__init__.py:23
msgid "Tip"
msgstr ""
#: sphinx/locale/__init__.py:24
msgid "Warning"
msgstr ""
#: sphinx/locale/__init__.py:28
#, python-format
msgid "New in version %s"
msgstr ""
#: sphinx/locale/__init__.py:29
#, python-format
msgid "Changed in version %s"
msgstr ""
#: sphinx/locale/__init__.py:30
#, python-format
msgid "Deprecated since version %s"
msgstr ""
#: sphinx/locale/__init__.py:34
msgid "module"
msgstr ""
#: sphinx/locale/__init__.py:35
msgid "keyword"
msgstr ""
#: sphinx/locale/__init__.py:36
msgid "operator"
msgstr ""
#: sphinx/locale/__init__.py:37
msgid "object"
msgstr ""
#: sphinx/locale/__init__.py:38
msgid "exception"
msgstr ""
#: sphinx/locale/__init__.py:39
msgid "statement"
msgstr ""
#: sphinx/locale/__init__.py:40
msgid "built-in function"
msgstr ""
#: sphinx/templates/defindex.html:2 #: sphinx/templates/defindex.html:2
msgid "Overview" msgid "Overview"
msgstr "" msgstr ""
@ -84,22 +349,11 @@ msgstr ""
msgid "all functions, classes, terms" msgid "all functions, classes, terms"
msgstr "" msgstr ""
#: sphinx/templates/genindex-single.html:2
#: sphinx/templates/genindex-split.html:2
#: sphinx/templates/genindex-split.html:5 sphinx/templates/genindex.html:2
#: sphinx/templates/genindex.html:5 sphinx/templates/genindex.html:48
msgid "Index"
msgstr ""
#: sphinx/templates/genindex-single.html:5 #: sphinx/templates/genindex-single.html:5
#, python-format #, python-format
msgid "Index &ndash; %(key)s" msgid "Index &ndash; %(key)s"
msgstr "" msgstr ""
#: sphinx/templates/genindex-single.html:14
msgid "Link"
msgstr ""
#: sphinx/templates/genindex-single.html:44 #: sphinx/templates/genindex-single.html:44
#: sphinx/templates/genindex-split.html:14 #: sphinx/templates/genindex-split.html:14
#: sphinx/templates/genindex-split.html:27 sphinx/templates/genindex.html:54 #: sphinx/templates/genindex-split.html:27 sphinx/templates/genindex.html:54

View File

@ -49,18 +49,19 @@ def indexmarkup_role(typ, rawtext, etext, lineno, inliner, options={}, content=[
inliner.document.note_explicit_target(targetnode) inliner.document.note_explicit_target(targetnode)
if typ == 'envvar': if typ == 'envvar':
env.note_index_entry('single', text, targetid, text) env.note_index_entry('single', text, targetid, text)
env.note_index_entry('single', 'environment variable; %s' % text, env.note_index_entry('single', _('environment variable; %s') % text,
targetid, text) targetid, text)
indexnode['entries'] = [('single', text, targetid, text), indexnode['entries'] = [('single', text, targetid, text),
('single', 'environment variable; %s' % text, ('single', _('environment variable; %s') % text,
targetid, text)] targetid, text)]
xref_nodes = xfileref_role(typ, rawtext, etext, lineno, inliner, xref_nodes = xfileref_role(typ, rawtext, etext, lineno, inliner,
options, content)[0] options, content)[0]
return [indexnode, targetnode] + xref_nodes, [] return [indexnode, targetnode] + xref_nodes, []
elif typ == 'pep': elif typ == 'pep':
env.note_index_entry('single', 'Python Enhancement Proposals!PEP %s' % text, env.note_index_entry('single', _('Python Enhancement Proposals!PEP %s') % text,
targetid, 'PEP %s' % text) targetid, 'PEP %s' % text)
indexnode['entries'] = [('single', 'Python Enhancement Proposals!PEP %s' % text, indexnode['entries'] = [('single',
_('Python Enhancement Proposals!PEP %s') % text,
targetid, 'PEP %s' % text)] targetid, 'PEP %s' % text)]
try: try:
pepnum = int(text) pepnum = int(text)

View File

@ -198,15 +198,8 @@
} }
% Lots of index-entry generation support. % Index-entry generation support.
% %
% Command to wrap around stuff that refers to function / module /
% attribute names in the index. Default behavior: like \code{}. To
% just keep the index entries in the roman font, uncomment the second
% definition; it matches O'Reilly style more.
%
\newcommand{\py@idxcode}[1]{\texttt{#1}}
%\renewcommand{\py@idxcode}[1]{#1}
% Command to generate two index entries (using subentries) % Command to generate two index entries (using subentries)
\newcommand{\indexii}[2]{\index{#1!#2}\index{#2!#1}} \newcommand{\indexii}[2]{\index{#1!#2}\index{#2!#1}}
@ -222,23 +215,6 @@
\index{#4!#1 #2 #3} \index{#4!#1 #2 #3}
} }
% Command to generate a reference to a function, statement, keyword,
% operator.
\newcommand{\kwindex}[1]{\indexii{keyword}{#1@{\py@idxcode{#1}}}}
\newcommand{\stindex}[1]{\indexii{statement}{#1@{\py@idxcode{#1}}}}
\newcommand{\opindex}[1]{\indexii{operator}{#1@{\py@idxcode{#1}}}}
\newcommand{\exindex}[1]{\indexii{exception}{#1@{\py@idxcode{#1}}}}
\newcommand{\obindex}[1]{\indexii{object}{#1}}
\newcommand{\bifuncindex}[1]{%
\index{#1@{\py@idxcode{#1()}} (built-in function)}}
% Add an index entry for a module
\newcommand{\py@refmodule}[2]{\index{#1@{\py@idxcode{#1}} (#2module)}}
\newcommand{\refmodindex}[1]{\py@refmodule{#1}{}}
\newcommand{\refbimodindex}[1]{\py@refmodule{#1}{built-in }}
\newcommand{\refexmodindex}[1]{\py@refmodule{#1}{extension }}
\newcommand{\refstmodindex}[1]{\py@refmodule{#1}{standard }}
% support for the module index % support for the module index
\newif\ifpy@UseModuleIndex \newif\ifpy@UseModuleIndex
\py@UseModuleIndexfalse \py@UseModuleIndexfalse
@ -256,7 +232,6 @@
% Add the defining entry for a module % Add the defining entry for a module
\newcommand{\py@modindex}[2]{% \newcommand{\py@modindex}[2]{%
\renewcommand{\py@thismodule}{#1} \renewcommand{\py@thismodule}{#1}
\index{#1@{\py@idxcode{#1}} (#2module)}%
\ifpy@UseModuleIndex% \ifpy@UseModuleIndex%
\@ifundefined{py@modplat@\py@thismodulekey}{ \@ifundefined{py@modplat@\py@thismodulekey}{
\write\modindexfile{\protect\indexentry{#1@{\texttt{#1}}|hyperpage}{\thepage}}% \write\modindexfile{\protect\indexentry{#1@{\texttt{#1}}|hyperpage}{\thepage}}%
@ -273,12 +248,6 @@
\newcommand{\py@thismoduletype}{} \newcommand{\py@thismoduletype}{}
\newcommand{\py@emptymodule}{} \newcommand{\py@emptymodule}{}
% Module index types
\newcommand{\py@standardIndexModule}[1]{\py@modindex{#1}{standard }}
\newcommand{\py@builtinIndexModule}[1]{\py@modindex{#1}{built-in }}
\newcommand{\py@extensionIndexModule}[1]{\py@modindex{#1}{extension }}
\newcommand{\py@IndexModule}[1]{\py@modindex{#1}{}}
% \declaremodule[key]{type}{name} % \declaremodule[key]{type}{name}
\newcommand{\declaremodule}[3][\py@modulebadkey]{ \newcommand{\declaremodule}[3][\py@modulebadkey]{
\renewcommand{\py@thismoduletype}{#2} \renewcommand{\py@thismoduletype}{#2}
@ -287,12 +256,7 @@
\else \else
\renewcommand{\py@thismodulekey}{#1} \renewcommand{\py@thismodulekey}{#1}
\fi \fi
\@ifundefined{py@#2IndexModule}{% \py@modindex{#3}{}
\typeout{*** MACRO declaremodule called with unknown module type: `#2'}
\py@IndexModule{#3}%
}{%
\csname py@#2IndexModule\endcsname{#3}%
}
%\label{module-\py@thismodulekey} %\label{module-\py@thismodulekey}
} }
@ -415,40 +379,30 @@
% tools/anno-api.py; it pulls the value from the refcounts database. % tools/anno-api.py; it pulls the value from the refcounts database.
\newcommand{\cfuncline}[3]{ \newcommand{\cfuncline}[3]{
\py@sigline{\code{#1 \bfcode{#2}}}{#3}% \py@sigline{\code{#1 \bfcode{#2}}}{#3}%
\index{#2@{\py@idxcode{#2()}}}
} }
\newenvironment{cfuncdesc}[4][\py@badkey]{ \newenvironment{cfuncdesc}[3]{
\begin{fulllineitems} \begin{fulllineitems}
\cfuncline{#2}{#3}{#4} \cfuncline{#1}{#2}{#3}
\ifx\@undefined#1\relax\else%
\emph{Return value: \textbf{#1}.}\\
\fi
}{\end{fulllineitems}} }{\end{fulllineitems}}
% C variables ------------------------------------------------------------ % C variables ------------------------------------------------------------
% \begin{cvardesc}{type}{name} % \begin{cvardesc}{type}{name}
\newenvironment{cvardesc}[2]{ \newenvironment{cvardesc}[2]{
\begin{fulllineitems} \begin{fulllineitems}
\item[\code{#1 \bfcode{#2}}\index{#2@{\py@idxcode{#2}}}] \item[\code{#1 \bfcode{#2}}]
}{\end{fulllineitems}} }{\end{fulllineitems}}
% C data types ----------------------------------------------------------- % C data types -----------------------------------------------------------
% \begin{ctypedesc}[index name]{typedef name} % \begin{ctypedesc}[index name]{typedef name}
\newenvironment{ctypedesc}[2][\py@badkey]{ \newenvironment{ctypedesc}[2][\py@badkey]{
\begin{fulllineitems} \begin{fulllineitems}
\item[\bfcode{#2}% \item[\bfcode{#2}]
\ifx\@undefined#1\relax%
\index{#2@{\py@idxcode{#2}} (C type)}
\else%
\index{#2@{\py@idxcode{#1}} (C type)}
\fi]
}{\end{fulllineitems}} }{\end{fulllineitems}}
% C type fields ---------------------------------------------------------- % C type fields ----------------------------------------------------------
% \begin{cmemberdesc}{container type}{ctype}{membername} % \begin{cmemberdesc}{container type}{ctype}{membername}
\newcommand{\cmemberline}[3]{ \newcommand{\cmemberline}[3]{
\item[\code{#2 \bfcode{#3}}] \item[\code{#2 \bfcode{#3}}]
\index{#3@{\py@idxcode{#3}} (#1 member)}
} }
\newenvironment{cmemberdesc}[3]{ \newenvironment{cmemberdesc}[3]{
\begin{fulllineitems} \begin{fulllineitems}
@ -460,18 +414,13 @@
% -- "simple" because it has no args; NOT for constant definitions! % -- "simple" because it has no args; NOT for constant definitions!
\newenvironment{csimplemacrodesc}[1]{ \newenvironment{csimplemacrodesc}[1]{
\begin{fulllineitems} \begin{fulllineitems}
\item[\bfcode{#1}\index{#1@{\py@idxcode{#1}} (macro)}] \item[\bfcode{#1}]
}{\end{fulllineitems}} }{\end{fulllineitems}}
% simple functions (not methods) ----------------------------------------- % simple functions (not methods) -----------------------------------------
% \begin{funcdesc}{name}{args} % \begin{funcdesc}{name}{args}
\newcommand{\funcline}[2]{% \newcommand{\funcline}[2]{%
\funclineni{#1}{#2}% \funclineni{#1}{#2}}
\ifx\py@thismodule\py@emptymodule%
\index{#1@{\py@idxcode{#1()}}}%
\else%
\index{#1@{\py@idxcode{#1()}} (in module \py@thismodule)}%
\fi}
\newenvironment{funcdesc}[2]{ \newenvironment{funcdesc}[2]{
\begin{fulllineitems} \begin{fulllineitems}
\funcline{#1}{#2} \funcline{#1}{#2}
@ -488,12 +437,7 @@
% classes ---------------------------------------------------------------- % classes ----------------------------------------------------------------
% \begin{classdesc}{name}{constructor args} % \begin{classdesc}{name}{constructor args}
\newcommand{\classline}[2]{ \newcommand{\classline}[2]{
\py@sigline{\strong{class }\bfcode{#1}}{#2}% \py@sigline{\strong{class }\bfcode{#1}}{#2}}
\ifx\py@thismodule\py@emptymodule%
\index{#1@{\py@idxcode{#1}} (class)}%
\else%
\index{#1@{\py@idxcode{#1}} (class in \py@thismodule)}%
\fi}
\newenvironment{classdesc}[2]{ \newenvironment{classdesc}[2]{
% Using \renewcommand doesn't work for this, for unknown reasons: % Using \renewcommand doesn't work for this, for unknown reasons:
\global\def\py@thisclass{#1} \global\def\py@thisclass{#1}
@ -515,12 +459,7 @@
% Using \renewcommand doesn't work for this, for unknown reasons: % Using \renewcommand doesn't work for this, for unknown reasons:
\global\def\py@thisclass{#1} \global\def\py@thisclass{#1}
\begin{fulllineitems} \begin{fulllineitems}
\item[\strong{class }\code{\bfcode{#1}}% \item[\strong{class }\code{\bfcode{#1}}]
\ifx\py@thismodule\py@emptymodule%
\index{#1@{\py@idxcode{#1}} (class)}%
\else%
\index{#1@{\py@idxcode{#1}} (class in \py@thismodule)}%
\fi]
}{\end{fulllineitems}} }{\end{fulllineitems}}
% \begin{excclassdesc}{name}{constructor args} % \begin{excclassdesc}{name}{constructor args}
@ -530,11 +469,6 @@
\global\def\py@thisclass{#1} \global\def\py@thisclass{#1}
\begin{fulllineitems} \begin{fulllineitems}
\py@sigline{\strong{exception }\bfcode{#1}}{#2}% \py@sigline{\strong{exception }\bfcode{#1}}{#2}%
\ifx\py@thismodule\py@emptymodule%
\index{#1@{\py@idxcode{#1}} (exception)}%
\else%
\index{#1@{\py@idxcode{#1}} (exception in \py@thismodule)}%
\fi
}{\end{fulllineitems}} }{\end{fulllineitems}}
% There is no corresponding {excclassdesc*} environment. To describe % There is no corresponding {excclassdesc*} environment. To describe
@ -547,11 +481,6 @@
% \begin{methoddesc}[classname]{methodname}{args} % \begin{methoddesc}[classname]{methodname}{args}
\newcommand{\methodline}[3][\@undefined]{ \newcommand{\methodline}[3][\@undefined]{
\methodlineni{#2}{#3} \methodlineni{#2}{#3}
\ifx\@undefined#1\relax
\index{#2@{\py@idxcode{#2()}} (\py@thisclass\ method)}
\else
\index{#2@{\py@idxcode{#2()}} (#1 method)}
\fi
} }
\newenvironment{methoddesc}[3][\@undefined]{ \newenvironment{methoddesc}[3][\@undefined]{
\begin{fulllineitems} \begin{fulllineitems}
@ -576,11 +505,6 @@
% \begin{staticmethoddesc}[classname]{methodname}{args} % \begin{staticmethoddesc}[classname]{methodname}{args}
\newcommand{\staticmethodline}[3][\@undefined]{ \newcommand{\staticmethodline}[3][\@undefined]{
\staticmethodlineni{#2}{#3} \staticmethodlineni{#2}{#3}
\ifx\@undefined#1\relax
\index{#2@{\py@idxcode{#2()}} (\py@thisclass\ static method)}
\else
\index{#2@{\py@idxcode{#2()}} (#1 static method)}
\fi
} }
\newenvironment{staticmethoddesc}[3][\@undefined]{ \newenvironment{staticmethoddesc}[3][\@undefined]{
\begin{fulllineitems} \begin{fulllineitems}
@ -606,10 +530,8 @@
\newcommand{\memberline}[2][\py@classbadkey]{% \newcommand{\memberline}[2][\py@classbadkey]{%
\ifx\@undefined#1\relax \ifx\@undefined#1\relax
\memberlineni{#2} \memberlineni{#2}
\index{#2@{\py@idxcode{#2}} (\py@thisclass\ attribute)}
\else \else
\memberlineni{#2} \memberlineni{#2}
\index{#2@{\py@idxcode{#2}} (#1 attribute)}
\fi \fi
} }
\newenvironment{memberdesc}[2][\py@classbadkey]{ \newenvironment{memberdesc}[2][\py@classbadkey]{
@ -635,22 +557,13 @@
% -- for constructor information, use excclassdesc instead % -- for constructor information, use excclassdesc instead
\newenvironment{excdesc}[1]{ \newenvironment{excdesc}[1]{
\begin{fulllineitems} \begin{fulllineitems}
\item[\strong{exception }\bfcode{#1}% \item[\strong{exception }\bfcode{#1}]
\ifx\py@thismodule\py@emptymodule%
\index{#1@{\py@idxcode{#1}} (exception)}%
\else%
\index{#1@{\py@idxcode{#1}} (exception in \py@thismodule)}%
\fi]
}{\end{fulllineitems}} }{\end{fulllineitems}}
% Module data or constants: ---------------------------------------------- % Module data or constants: ----------------------------------------------
% \begin{datadesc}{name} % \begin{datadesc}{name}
\newcommand{\dataline}[1]{% \newcommand{\dataline}[1]{%
\datalineni{#1}\ifx\py@thismodule\py@emptymodule% \datalineni{#1}}
\index{#1@{\py@idxcode{#1}} (data)}%
\else%
\index{#1@{\py@idxcode{#1}} (data in \py@thismodule)}%
\fi}
\newenvironment{datadesc}[1]{ \newenvironment{datadesc}[1]{
\begin{fulllineitems} \begin{fulllineitems}
\dataline{#1} \dataline{#1}
@ -722,90 +635,32 @@
} }
% Some are quite plain: % Some are quite plain:
\newcommand{\py@noticelabel@note}{Note:}
\newcommand{\py@noticestart@note}{} \newcommand{\py@noticestart@note}{}
\newcommand{\py@noticeend@note}{} \newcommand{\py@noticeend@note}{}
\newcommand{\py@noticelabel@hint}{Hint:}
\newcommand{\py@noticestart@hint}{} \newcommand{\py@noticestart@hint}{}
\newcommand{\py@noticeend@hint}{} \newcommand{\py@noticeend@hint}{}
\newcommand{\py@noticelabel@important}{Important:}
\newcommand{\py@noticestart@important}{} \newcommand{\py@noticestart@important}{}
\newcommand{\py@noticeend@important}{} \newcommand{\py@noticeend@important}{}
\newcommand{\py@noticelabel@tip}{Tip:}
\newcommand{\py@noticestart@tip}{} \newcommand{\py@noticestart@tip}{}
\newcommand{\py@noticeend@tip}{} \newcommand{\py@noticeend@tip}{}
% Others gets more visible distinction: % Others gets more visible distinction:
\newcommand{\py@noticelabel@warning}{Warning:}
\newcommand{\py@noticestart@warning}{\py@heavybox} \newcommand{\py@noticestart@warning}{\py@heavybox}
\newcommand{\py@noticeend@warning}{\py@endheavybox} \newcommand{\py@noticeend@warning}{\py@endheavybox}
\newcommand{\py@noticelabel@caution}{Caution:}
\newcommand{\py@noticestart@caution}{\py@heavybox} \newcommand{\py@noticestart@caution}{\py@heavybox}
\newcommand{\py@noticeend@caution}{\py@endheavybox} \newcommand{\py@noticeend@caution}{\py@endheavybox}
\newcommand{\py@noticelabel@attention}{Attention:}
\newcommand{\py@noticestart@attention}{\py@heavybox} \newcommand{\py@noticestart@attention}{\py@heavybox}
\newcommand{\py@noticeend@attention}{\py@endheavybox} \newcommand{\py@noticeend@attention}{\py@endheavybox}
\newcommand{\py@noticelabel@danger}{Danger:}
\newcommand{\py@noticestart@danger}{\py@heavybox} \newcommand{\py@noticestart@danger}{\py@heavybox}
\newcommand{\py@noticeend@danger}{\py@endheavybox} \newcommand{\py@noticeend@danger}{\py@endheavybox}
\newcommand{\py@noticelabel@error}{Error:}
\newcommand{\py@noticestart@error}{\py@heavybox} \newcommand{\py@noticestart@error}{\py@heavybox}
\newcommand{\py@noticeend@error}{\py@endheavybox} \newcommand{\py@noticeend@error}{\py@endheavybox}
\newenvironment{notice}[2]{
\newenvironment{notice}[1][note]{
\def\py@noticetype{#1} \def\py@noticetype{#1}
\csname py@noticestart@#1\endcsname \csname py@noticestart@#1\endcsname
\par\strong{\csname py@noticelabel@#1\endcsname} \par\strong{#2}
}{\csname py@noticeend@\py@noticetype\endcsname} }{\csname py@noticeend@\py@noticetype\endcsname}
\newcommand{\note}[1]{\strong{\py@noticelabel@note} #1}
\newcommand{\warning}[1]{\strong{\py@noticelabel@warning} #1}
% Deprecation stuff.
% Should be extended to allow an index / list of deprecated stuff. But
% there's a lot of stuff that needs to be done to make that automatable.
%
% First parameter is the release number that deprecates the feature, the
% second is the action the should be taken by users of the feature.
%
% Example:
% \deprecated{1.5.1}{Use \method{frobnicate()} instead.}
%
\newcommand{\deprecated}[2]{%
\strong{Deprecated since release #1.} #2\par}
% New stuff.
% This should be used to mark things which have been added to the
% development tree but that aren't in the release, but are documented.
% This allows release of documentation that already includes updated
% descriptions. Place at end of descriptor environment.
%
% Example:
% \versionadded{1.5.2}
% \versionchanged[short explanation]{2.0}
%
\newcommand{\versionadded}[2][\py@badkey]{%
\ifx\@undefined#1\relax%
{ New in version #2. }%
\else%
{ New in version #2:\ #1 }%
\fi%
}
\newcommand{\versionchanged}[2][\py@badkey]{%
\ifx\@undefined#1\relax%
{ Changed in version #2. }%
\else%
{ Changed in version #2:\ #1 }%
\fi%
}
% See-also environment
\newenvironment{seealso}{
\par
\strong{See Also:}
\par
}{\par}
% Allow the release number to be specified independently of the % Allow the release number to be specified independently of the
% \date{}. This allows the date to reflect the document's date and % \date{}. This allows the date to reflect the document's date and

View File

@ -15,6 +15,7 @@ import textwrap
from docutils import nodes, writers from docutils import nodes, writers
from sphinx import addnodes from sphinx import addnodes
from sphinx.locale import admonitionlabels, versionlabels
class TextWriter(writers.Writer): class TextWriter(writers.Writer):
@ -147,7 +148,7 @@ class TextTranslator(nodes.NodeVisitor):
def visit_module(self, node): def visit_module(self, node):
if node.has_key('platform'): if node.has_key('platform'):
self.new_state(0) self.new_state(0)
self.add_text('Platform: %s' % node['platform']) self.add_text(_('Platform: %s') % node['platform'])
self.end_state() self.end_state()
raise nodes.SkipNode raise nodes.SkipNode
@ -349,7 +350,7 @@ class TextTranslator(nodes.NodeVisitor):
raise nodes.SkipNode raise nodes.SkipNode
def visit_image(self, node): def visit_image(self, node):
self.add_text('[image]') self.add_text(_('[image]'))
raise nodes.SkipNode raise nodes.SkipNode
def visit_transition(self, node): def visit_transition(self, node):
@ -446,46 +447,38 @@ class TextTranslator(nodes.NodeVisitor):
def depart_admonition(self, node): def depart_admonition(self, node):
self.end_state() self.end_state()
def _make_visit_admonition(name):
def visit_admonition(self, node): def visit_admonition(self, node):
self.new_state(2) self.new_state(2)
return visit_admonition
def _make_depart_admonition(name): def _make_depart_admonition(name):
def depart_admonition(self, node): def depart_admonition(self, node):
self.end_state(first=name.capitalize() + ': ') self.end_state(first=admonitionlabels[name] + ': ')
return depart_admonition return depart_admonition
visit_attention = _make_visit_admonition('attention') visit_attention = visit_admonition
depart_attention = _make_depart_admonition('attention') depart_attention = _make_depart_admonition('attention')
visit_caution = _make_visit_admonition('caution') visit_caution = visit_admonition
depart_caution = _make_depart_admonition('caution') depart_caution = _make_depart_admonition('caution')
visit_danger = _make_visit_admonition('danger') visit_danger = visit_admonition
depart_danger = _make_depart_admonition('danger') depart_danger = _make_depart_admonition('danger')
visit_error = _make_visit_admonition('error') visit_error = visit_admonition
depart_error = _make_depart_admonition('error') depart_error = _make_depart_admonition('error')
visit_hint = _make_visit_admonition('hint') visit_hint = visit_admonition
depart_hint = _make_depart_admonition('hint') depart_hint = _make_depart_admonition('hint')
visit_important = _make_visit_admonition('important') visit_important = visit_admonition
depart_important = _make_depart_admonition('important') depart_important = _make_depart_admonition('important')
visit_note = _make_visit_admonition('note') visit_note = visit_admonition
depart_note = _make_depart_admonition('note') depart_note = _make_depart_admonition('note')
visit_tip = _make_visit_admonition('tip') visit_tip = visit_admonition
depart_tip = _make_depart_admonition('tip') depart_tip = _make_depart_admonition('tip')
visit_warning = _make_visit_admonition('warning') visit_warning = visit_admonition
depart_warning = _make_depart_admonition('warning') depart_warning = _make_depart_admonition('warning')
def visit_versionmodified(self, node): def visit_versionmodified(self, node):
self.new_state(0) self.new_state(0)
if node['type'] == 'versionadded':
tmpl = 'Added in version %s'
elif node['type'] == 'versionchanged':
tmpl = 'Changed in version %s'
elif node['type'] == 'deprecated':
tmpl = 'Deprecated in version %s'
if node.children: if node.children:
self.add_text(tmpl % node['version'] + ': ') self.add_text(versionlabels[node['type']] % node['version'] + ': ')
else: else:
self.add_text(tmpl % node['version'] + '.') self.add_text(versionlabels[node['type']] % node['version'] + '.')
def depart_versionmodified(self, node): def depart_versionmodified(self, node):
self.end_state() self.end_state()
@ -606,4 +599,4 @@ class TextTranslator(nodes.NodeVisitor):
raise nodes.SkipNode raise nodes.SkipNode
def unknown_visit(self, node): def unknown_visit(self, node):
raise NotImplementedError("Unknown node: " + node.__class__.__name__) raise NotImplementedError('Unknown node: ' + node.__class__.__name__)

View File

@ -189,7 +189,7 @@ def educateQuotes(s):
return s.replace('"', "&#8220;") return s.replace('"', "&#8220;")
def educateQuotesLatex(s): def educateQuotesLatex(s, dquotes=("``", "''")):
""" """
Parameter: String. Parameter: String.
@ -227,7 +227,7 @@ def educateQuotesLatex(s):
s = s.replace('"', "\x01") s = s.replace('"', "\x01")
# Finally, replace all helpers with quotes. # Finally, replace all helpers with quotes.
return s.replace("\x01", "``").replace("\x02", "''").\ return s.replace("\x01", dquotes[0]).replace("\x02", dquotes[1]).\
replace("\x03", "`").replace("\x04", "'") replace("\x03", "`").replace("\x04", "'")

17
tests/test_i18n.py Normal file
View File

@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
"""
test_i18n
~~~~~~~~~
Test locale features.
:copyright: 2008 by Georg Brandl.
:license: BSD.
"""
from util import *
@with_testapp(confoverrides={'language': 'de'})
def test_i18n(app):
app.builder.build_all()