Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > bd9b8648918182c52f8a2d496fcd571e > files > 93

python-genshi-0.5.1-3mdv2010.0.i586.rpm

<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>genshi.filters.i18n.Translator</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="genshi-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="../index.html">Documentation Index</a></th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="genshi-module.html">Package&nbsp;genshi</a> ::
        <a href="genshi.filters-module.html">Package&nbsp;filters</a> ::
        <a href="genshi.filters.i18n-module.html">Module&nbsp;i18n</a> ::
        Class&nbsp;Translator
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
      </table>
    </td>
  </tr>
</table>
<!-- ==================== CLASS DESCRIPTION ==================== -->
<h1 class="epydoc">Class Translator</h1><p class="nomargin-top"></p>
<pre class="base-tree">
object --+
         |
        <strong class="uidshort">Translator</strong>
</pre>

<hr />
<p>Can extract and translate localizable strings from markup streams and
templates.</p>
<p>For example, assume the followng template:</p>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">from</span> genshi.template <span class="py-keyword">import</span> MarkupTemplate
<span class="py-prompt">&gt;&gt;&gt;</span>
<span class="py-prompt">&gt;&gt;&gt; </span>tmpl = MarkupTemplate(<span class="py-string">'''&lt;html xmlns:py=&quot;http://genshi.edgewall.org/&quot;&gt;</span>
<span class="py-more">... </span><span class="py-string">  &lt;head&gt;</span>
<span class="py-more">... </span><span class="py-string">    &lt;title&gt;Example&lt;/title&gt;</span>
<span class="py-more">... </span><span class="py-string">  &lt;/head&gt;</span>
<span class="py-more">... </span><span class="py-string">  &lt;body&gt;</span>
<span class="py-more">... </span><span class="py-string">    &lt;h1&gt;Example&lt;/h1&gt;</span>
<span class="py-more">... </span><span class="py-string">    &lt;p&gt;${_(&quot;Hello, %(name)s&quot;) % dict(name=username)}&lt;/p&gt;</span>
<span class="py-more">... </span><span class="py-string">  &lt;/body&gt;</span>
<span class="py-more">... </span><span class="py-string">&lt;/html&gt;'''</span>, filename=<span class="py-string">'example.html'</span>)</pre>
<p>For demonstration, we define a dummy <tt class="rst-docutils literal"><span class="pre">gettext</span></tt>-style function with a
hard-coded translation table, and pass that to the <a href="genshi.filters.i18n.Translator-class.html" class="link">Translator</a> initializer:</p>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">def</span> <span class="py-defname">pseudo_gettext</span>(string):
<span class="py-more">... </span>    return {
<span class="py-more">... </span>        <span class="py-string">'Example'</span>: <span class="py-string">'Beispiel'</span>,
<span class="py-more">... </span>        <span class="py-string">'Hello, %(name)s'</span>: <span class="py-string">'Hallo, %(name)s'</span>
<span class="py-more">... </span>    }[string]
<span class="py-prompt">&gt;&gt;&gt;</span>
<span class="py-prompt">&gt;&gt;&gt; </span>translator = Translator(pseudo_gettext)</pre>
<p>Next, the translator needs to be prepended to any already defined filters
on the template:</p>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span>tmpl.filters.insert(0, translator)</pre>
<p>When generating the template output, our hard-coded translations should be
applied as expected:</p>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">print</span> tmpl.generate(username=<span class="py-string">'Hans'</span>, _=pseudo_gettext)
<span class="py-output">&lt;html&gt;</span>
<span class="py-output">  &lt;head&gt;</span>
<span class="py-output">    &lt;title&gt;Beispiel&lt;/title&gt;</span>
<span class="py-output">  &lt;/head&gt;</span>
<span class="py-output">  &lt;body&gt;</span>
<span class="py-output">    &lt;h1&gt;Beispiel&lt;/h1&gt;</span>
<span class="py-output">    &lt;p&gt;Hallo, Hans&lt;/p&gt;</span>
<span class="py-output">  &lt;/body&gt;</span>
<span class="py-output">&lt;/html&gt;</span></pre>
<p>Note that elements defining <tt class="rst-docutils literal"><span class="pre">xml:lang</span></tt> attributes that do not contain
variable expressions are ignored by this filter. That can be used to
exclude specific parts of a template from being extracted and translated.</p>

<!-- ==================== INSTANCE METHODS ==================== -->
<a name="section-InstanceMethods"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td align="left" colspan="2" class="table-header">
    <span class="table-header">Instance Methods</span></td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="genshi.filters.i18n.Translator-class.html#__init__" class="summary-sig-name">__init__</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">translate</span>=<span class="summary-sig-default">&lt;function gettext at 0x6484f0&gt;</span>,
        <span class="summary-sig-arg">ignore_tags</span>=<span class="summary-sig-default"><code class="variable-group">frozenset([</code>QName(u'script')<code class="variable-op">, </code>QName(u'style')<code class="variable-op">, </code>QName(u'http://w<code class="variable-ellipsis">...</code></span>,
        <span class="summary-sig-arg">include_attrs</span>=<span class="summary-sig-default"><code class="variable-group">frozenset([</code><code class="variable-quote">'</code><code class="variable-string">abbr</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">alt</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">label</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">prompt</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">standby</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">summa</code><code class="variable-ellipsis">...</code></span>,
        <span class="summary-sig-arg">extract_text</span>=<span class="summary-sig-default">True</span>)</span><br />
      Initialize the translator.</td>
          <td align="right" valign="top">
            
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="genshi.filters.i18n.Translator-class.html#__call__" class="summary-sig-name">__call__</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">stream</span>,
        <span class="summary-sig-arg">ctxt</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">search_text</span>=<span class="summary-sig-default">True</span>,
        <span class="summary-sig-arg">msgbuf</span>=<span class="summary-sig-default">None</span>)</span><br />
      Translate any localizable strings in the given stream.</td>
          <td align="right" valign="top">
            
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="genshi.filters.i18n.Translator-class.html#extract" class="summary-sig-name">extract</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">stream</span>,
        <span class="summary-sig-arg">gettext_functions</span>=<span class="summary-sig-default"><code class="variable-group">(</code><code class="variable-quote">'</code><code class="variable-string">_</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">gettext</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">ngettext</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">dgettext</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">dngettext</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">ugettex</code><code class="variable-ellipsis">...</code></span>,
        <span class="summary-sig-arg">search_text</span>=<span class="summary-sig-default">True</span>,
        <span class="summary-sig-arg">msgbuf</span>=<span class="summary-sig-default">None</span>)</span><br />
      Extract localizable strings from the given template stream.</td>
          <td align="right" valign="top">
            
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
  <tr>
    <td colspan="2" class="summary">
    <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
      <code>__delattr__</code>,
      <code>__getattribute__</code>,
      <code>__hash__</code>,
      <code>__new__</code>,
      <code>__reduce__</code>,
      <code>__reduce_ex__</code>,
      <code>__repr__</code>,
      <code>__setattr__</code>,
      <code>__str__</code>
      </p>
    </td>
  </tr>
</table>
<!-- ==================== CLASS VARIABLES ==================== -->
<a name="section-ClassVariables"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td align="left" colspan="2" class="table-header">
    <span class="table-header">Class Variables</span></td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a href="genshi.filters.i18n.Translator-class.html#IGNORE_TAGS" class="summary-name">IGNORE_TAGS</a> = <code title="frozenset([QName(u'script'),
           QName(u'style'),
           QName(u'http://www.w3.org/1999/xhtml}script'),
           QName(u'http://www.w3.org/1999/xhtml}style')])"><code class="variable-group">frozenset([</code>QName(u'script')<code class="variable-op">, </code>QName(u'style')<code class="variable-op">, </code>QN<code class="variable-ellipsis">...</code></code>
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a href="genshi.filters.i18n.Translator-class.html#INCLUDE_ATTRS" class="summary-name">INCLUDE_ATTRS</a> = <code title="frozenset(['abbr',
           'alt',
           'label',
           'prompt',
           'standby',
           'summary',
           'title'])"><code class="variable-group">frozenset([</code><code class="variable-quote">'</code><code class="variable-string">abbr</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">alt</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">label</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">prompt</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-ellipsis">...</code></code>
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a href="genshi.filters.i18n.Translator-class.html#GETTEXT_FUNCTIONS" class="summary-name">GETTEXT_FUNCTIONS</a> = <code title="('_',
 'gettext',
 'ngettext',
 'dgettext',
 'dngettext',
 'ugettext',
 'ungettext')"><code class="variable-group">(</code><code class="variable-quote">'</code><code class="variable-string">_</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">gettext</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">ngettext</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">dgettext</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-ellipsis">...</code></code>
    </td>
  </tr>
</table>
<!-- ==================== PROPERTIES ==================== -->
<a name="section-Properties"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td align="left" colspan="2" class="table-header">
    <span class="table-header">Properties</span></td>
</tr>
  <tr>
    <td colspan="2" class="summary">
    <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
      <code>__class__</code>
      </p>
    </td>
  </tr>
</table>
<!-- ==================== METHOD DETAILS ==================== -->
<a name="section-MethodDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td align="left" colspan="2" class="table-header">
    <span class="table-header">Method Details</span></td>
</tr>
</table>
<a name="__init__"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__init__</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">translate</span>=<span class="sig-default">&lt;function gettext at 0x6484f0&gt;</span>,
        <span class="sig-arg">ignore_tags</span>=<span class="sig-default"><code class="variable-group">frozenset([</code>QName(u'script')<code class="variable-op">, </code>QName(u'style')<code class="variable-op">, </code>QName(u'http://w<code class="variable-ellipsis">...</code></span>,
        <span class="sig-arg">include_attrs</span>=<span class="sig-default"><code class="variable-group">frozenset([</code><code class="variable-quote">'</code><code class="variable-string">abbr</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">alt</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">label</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">prompt</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">standby</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">summa</code><code class="variable-ellipsis">...</code></span>,
        <span class="sig-arg">extract_text</span>=<span class="sig-default">True</span>)</span>
    <br /><em class="fname">(Constructor)</em>
  </h3>
  </td><td align="right" valign="top"
    >&nbsp;
    </td>
  </tr></table>
  
  Initialize the translator.
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>translate</code></strong> - the translation function, for example <tt class="rst-docutils literal"><span class="pre">gettext</span></tt> or
<tt class="rst-docutils literal"><span class="pre">ugettext</span></tt>.</li>
        <li><strong class="pname"><code>ignore_tags</code></strong> - a set of tag names that should not be localized</li>
        <li><strong class="pname"><code>include_attrs</code></strong> - a set of attribute names should be localized</li>
        <li><strong class="pname"><code>extract_text</code></strong> - whether the content of text nodes should be
extracted, or only text in explicit <tt class="rst-docutils literal"><span class="pre">gettext</span></tt>
function calls</li>
    </ul></dd>
    <dt>Overrides:
        object.__init__
    </dt>
  </dl>
</td></tr></table>
</div>
<a name="__call__"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__call__</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">stream</span>,
        <span class="sig-arg">ctxt</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">search_text</span>=<span class="sig-default">True</span>,
        <span class="sig-arg">msgbuf</span>=<span class="sig-default">None</span>)</span>
    <br /><em class="fname">(Call operator)</em>
  </h3>
  </td><td align="right" valign="top"
    >&nbsp;
    </td>
  </tr></table>
  
  <p>Translate any localizable strings in the given stream.</p>
<p>This function shouldn't be called directly. Instead, an instance of
the <a href="genshi.filters.i18n.Translator-class.html" class="link">Translator</a> class should be registered as a filter with the
<a href="genshi.template.base.Template-class.html" class="link">Template</a> or the <a href="genshi.template.loader.TemplateLoader-class.html" class="link">TemplateLoader</a>, or applied as a regular stream
filter. If used as a template filter, it should be inserted in front of
all the default filters.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>stream</code></strong> - the markup event stream</li>
        <li><strong class="pname"><code>ctxt</code></strong> - the template context (not used)</li>
        <li><strong class="pname"><code>search_text</code></strong> - whether text nodes should be translated (used
internally)</li>
        <li><strong class="pname"><code>msgbuf</code></strong> - a MessageBuffer object or <code class="link">None</code> (used internally)</li>
    </ul></dd>
    <dt>Returns:</dt>
        <dd>the localized stream</dd>
  </dl>
</td></tr></table>
</div>
<a name="extract"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">extract</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">stream</span>,
        <span class="sig-arg">gettext_functions</span>=<span class="sig-default"><code class="variable-group">(</code><code class="variable-quote">'</code><code class="variable-string">_</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">gettext</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">ngettext</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">dgettext</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">dngettext</code><code class="variable-quote">'</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">ugettex</code><code class="variable-ellipsis">...</code></span>,
        <span class="sig-arg">search_text</span>=<span class="sig-default">True</span>,
        <span class="sig-arg">msgbuf</span>=<span class="sig-default">None</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    >&nbsp;
    </td>
  </tr></table>
  
  <p>Extract localizable strings from the given template stream.</p>
<p>For every string found, this function yields a <tt class="rst-docutils literal"><span class="pre">(lineno,</span> <span class="pre">function,</span>
<span class="pre">message)</span></tt> tuple, where:</p>
<ul class="rst-simple">
<li><tt class="rst-docutils literal"><span class="pre">lineno</span></tt> is the number of the line on which the string was found,</li>
<li><tt class="rst-docutils literal"><span class="pre">function</span></tt> is the name of the <tt class="rst-docutils literal"><span class="pre">gettext</span></tt> function used (if the
string was extracted from embedded Python code), and</li>
<li><tt class="rst-docutils literal"><span class="pre">message</span></tt> is the string itself (a <tt class="rst-docutils literal"><span class="pre">unicode</span></tt> object, or a tuple
of <tt class="rst-docutils literal"><span class="pre">unicode</span></tt> objects for functions with multiple string arguments).</li>
</ul>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">from</span> genshi.template <span class="py-keyword">import</span> MarkupTemplate
<span class="py-prompt">&gt;&gt;&gt;</span>
<span class="py-prompt">&gt;&gt;&gt; </span>tmpl = MarkupTemplate(<span class="py-string">'''&lt;html xmlns:py=&quot;http://genshi.edgewall.org/&quot;&gt;</span>
<span class="py-more">... </span><span class="py-string">  &lt;head&gt;</span>
<span class="py-more">... </span><span class="py-string">    &lt;title&gt;Example&lt;/title&gt;</span>
<span class="py-more">... </span><span class="py-string">  &lt;/head&gt;</span>
<span class="py-more">... </span><span class="py-string">  &lt;body&gt;</span>
<span class="py-more">... </span><span class="py-string">    &lt;h1&gt;Example&lt;/h1&gt;</span>
<span class="py-more">... </span><span class="py-string">    &lt;p&gt;${_(&quot;Hello, %(name)s&quot;) % dict(name=username)}&lt;/p&gt;</span>
<span class="py-more">... </span><span class="py-string">    &lt;p&gt;${ngettext(&quot;You have %d item&quot;, &quot;You have %d items&quot;, num)}&lt;/p&gt;</span>
<span class="py-more">... </span><span class="py-string">  &lt;/body&gt;</span>
<span class="py-more">... </span><span class="py-string">&lt;/html&gt;'''</span>, filename=<span class="py-string">'example.html'</span>)
<span class="py-prompt">&gt;&gt;&gt;</span>
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">for</span> lineno, funcname, message <span class="py-keyword">in</span> Translator().extract(tmpl.stream):
<span class="py-more">... </span>   <span class="py-keyword">print</span> <span class="py-string">&quot;%d, %r, %r&quot;</span> % (lineno, funcname, message)
<span class="py-output">3, None, u'Example'</span>
<span class="py-output">6, None, u'Example'</span>
<span class="py-output">7, '_', u'Hello, %(name)s'</span>
<span class="py-output">8, 'ngettext', (u'You have %d item', u'You have %d items', None)</span></pre>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>stream</code></strong> - the event stream to extract strings from; can be a
regular stream or a template stream</li>
        <li><strong class="pname"><code>gettext_functions</code></strong> - a sequence of function names that should be
treated as gettext-style localization
functions</li>
        <li><strong class="pname"><code>search_text</code></strong> - whether the content of text nodes should be
extracted (used internally)</li>
    </ul></dd>
  </dl>
<div class="fields">      <p><strong>Note:</strong>
        Changed in 0.4.1: For a function with multiple string arguments
(such as <tt class="rst-docutils literal"><span class="pre">ngettext</span></tt>), a single item with a tuple of strings is
yielded, instead an item for each string argument.
      </p>
</div></td></tr></table>
</div>
<br />
<!-- ==================== CLASS VARIABLE DETAILS ==================== -->
<a name="section-ClassVariableDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td align="left" colspan="2" class="table-header">
    <span class="table-header">Class Variable Details</span></td>
</tr>
</table>
<a name="IGNORE_TAGS"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <h3 class="epydoc">IGNORE_TAGS</h3>
  
  <dl class="fields">
  </dl>
  <dl class="fields">
    <dt>Value:</dt>
      <dd><table><tr><td><pre class="variable">
<code class="variable-group">frozenset([</code>QName(u'script')<code class="variable-op">,</code>
           QName(u'style')<code class="variable-op">,</code>
           QName(u'http://www.w3.org/1999/xhtml}script')<code class="variable-op">,</code>
           QName(u'http://www.w3.org/1999/xhtml}style')<code class="variable-group">])</code>
</pre></td></tr></table>
</dd>
  </dl>
</td></tr></table>
</div>
<a name="INCLUDE_ATTRS"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <h3 class="epydoc">INCLUDE_ATTRS</h3>
  
  <dl class="fields">
  </dl>
  <dl class="fields">
    <dt>Value:</dt>
      <dd><table><tr><td><pre class="variable">
<code class="variable-group">frozenset([</code><code class="variable-quote">'</code><code class="variable-string">abbr</code><code class="variable-quote">'</code><code class="variable-op">,</code>
           <code class="variable-quote">'</code><code class="variable-string">alt</code><code class="variable-quote">'</code><code class="variable-op">,</code>
           <code class="variable-quote">'</code><code class="variable-string">label</code><code class="variable-quote">'</code><code class="variable-op">,</code>
           <code class="variable-quote">'</code><code class="variable-string">prompt</code><code class="variable-quote">'</code><code class="variable-op">,</code>
           <code class="variable-quote">'</code><code class="variable-string">standby</code><code class="variable-quote">'</code><code class="variable-op">,</code>
           <code class="variable-quote">'</code><code class="variable-string">summary</code><code class="variable-quote">'</code><code class="variable-op">,</code>
           <code class="variable-quote">'</code><code class="variable-string">title</code><code class="variable-quote">'</code><code class="variable-group">])</code>
</pre></td></tr></table>
</dd>
  </dl>
</td></tr></table>
</div>
<a name="GETTEXT_FUNCTIONS"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <h3 class="epydoc">GETTEXT_FUNCTIONS</h3>
  
  <dl class="fields">
  </dl>
  <dl class="fields">
    <dt>Value:</dt>
      <dd><table><tr><td><pre class="variable">
<code class="variable-group">(</code><code class="variable-quote">'</code><code class="variable-string">_</code><code class="variable-quote">'</code><code class="variable-op">,</code>
 <code class="variable-quote">'</code><code class="variable-string">gettext</code><code class="variable-quote">'</code><code class="variable-op">,</code>
 <code class="variable-quote">'</code><code class="variable-string">ngettext</code><code class="variable-quote">'</code><code class="variable-op">,</code>
 <code class="variable-quote">'</code><code class="variable-string">dgettext</code><code class="variable-quote">'</code><code class="variable-op">,</code>
 <code class="variable-quote">'</code><code class="variable-string">dngettext</code><code class="variable-quote">'</code><code class="variable-op">,</code>
 <code class="variable-quote">'</code><code class="variable-string">ugettext</code><code class="variable-quote">'</code><code class="variable-op">,</code>
 <code class="variable-quote">'</code><code class="variable-string">ungettext</code><code class="variable-quote">'</code><code class="variable-group">)</code>
</pre></td></tr></table>
</dd>
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="genshi-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="../index.html">Documentation Index</a></th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Wed Jul  9 18:16:20 2008
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>