~ubuntu-branches/ubuntu/raring/genshi/raring-proposed

« back to all changes in this revision

Viewing changes to doc/api/genshi.filters.i18n.Translator-class.html

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Fontaine
  • Date: 2007-04-16 17:49:03 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20070416174903-x2p3n9g890v18d0m
Tags: 0.4-1
* New upstream release.
* Remove useless python-markup transition package.
* Add Provides against python-markup.
* Add doc-base.
* Add depends against python-xml.
* Add suggests to python-setuptools.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="ascii"?>
 
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 
3
          "DTD/xhtml1-transitional.dtd">
 
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
5
<head>
 
6
  <title>genshi.filters.i18n.Translator</title>
 
7
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
 
8
  <script type="text/javascript" src="epydoc.js"></script>
 
9
</head>
 
10
 
 
11
<body bgcolor="white" text="black" link="blue" vlink="#204080"
 
12
      alink="#204080">
 
13
<!-- ==================== NAVIGATION BAR ==================== -->
 
14
<table class="navbar" border="0" width="100%" cellpadding="0"
 
15
       bgcolor="#a0c0ff" cellspacing="0">
 
16
  <tr valign="middle">
 
17
  <!-- Home link -->
 
18
      <th>&nbsp;&nbsp;&nbsp;<a
 
19
        href="genshi-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
 
20
 
 
21
  <!-- Tree link -->
 
22
      <th>&nbsp;&nbsp;&nbsp;<a
 
23
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
 
24
 
 
25
  <!-- Index link -->
 
26
      <th>&nbsp;&nbsp;&nbsp;<a
 
27
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>
 
28
 
 
29
  <!-- Help link -->
 
30
      <th>&nbsp;&nbsp;&nbsp;<a
 
31
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
 
32
 
 
33
  <!-- Project homepage -->
 
34
      <th class="navbar" align="right" width="100%">
 
35
        <table border="0" cellpadding="0" cellspacing="0">
 
36
          <tr><th class="navbar" align="center"
 
37
            ><a class="navbar" target="_top" href="../index.html">Documentation Index</a></th>
 
38
          </tr></table></th>
 
39
  </tr>
 
40
</table>
 
41
<table width="100%" cellpadding="0" cellspacing="0">
 
42
  <tr valign="top">
 
43
    <td width="100%">
 
44
      <span class="breadcrumbs">
 
45
        <a href="genshi-module.html">Package&nbsp;genshi</a> ::
 
46
        <a href="genshi.filters-module.html">Package&nbsp;filters</a> ::
 
47
        <a href="genshi.filters.i18n-module.html">Module&nbsp;i18n</a> ::
 
48
        Class&nbsp;Translator
 
49
      </span>
 
50
    </td>
 
51
    <td>
 
52
      <table cellpadding="0" cellspacing="0">
 
53
        <!-- hide/show private -->
 
54
      </table>
 
55
    </td>
 
56
  </tr>
 
57
</table>
 
58
<!-- ==================== CLASS DESCRIPTION ==================== -->
 
59
<h1 class="epydoc">Class Translator</h1><br /><br />
 
60
<pre class="base-tree">
 
61
object --+
 
62
         |
 
63
        <strong class="uidshort">Translator</strong>
 
64
</pre>
 
65
 
 
66
<hr />
 
67
<p>Can extract and translate localizable strings from markup streams and
 
68
templates.</p>
 
69
<p>For example, assume the followng template:</p>
 
70
<pre class="py-doctest">
 
71
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">from</span> genshi.template <span class="py-keyword">import</span> MarkupTemplate
 
72
<span class="py-prompt">&gt;&gt;&gt;</span>
 
73
<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>
 
74
<span class="py-more">... </span><span class="py-string">  &lt;head&gt;</span>
 
75
<span class="py-more">... </span><span class="py-string">    &lt;title&gt;Example&lt;/title&gt;</span>
 
76
<span class="py-more">... </span><span class="py-string">  &lt;/head&gt;</span>
 
77
<span class="py-more">... </span><span class="py-string">  &lt;body&gt;</span>
 
78
<span class="py-more">... </span><span class="py-string">    &lt;h1&gt;Example&lt;/h1&gt;</span>
 
79
<span class="py-more">... </span><span class="py-string">    &lt;p&gt;${_(&quot;Hello, %(name)s&quot;) % dict(name=username)}&lt;/p&gt;</span>
 
80
<span class="py-more">... </span><span class="py-string">  &lt;/body&gt;</span>
 
81
<span class="py-more">... </span><span class="py-string">&lt;/html&gt;'''</span>, filename=<span class="py-string">'example.html'</span>)</pre>
 
82
<p>For demonstration, we define a dummy <tt class="rst-docutils literal"><span class="pre">gettext</span></tt>-style function with a
 
83
hard-coded translation table, and pass that to the <a href="genshi.filters.i18n.Translator-class.html" class="link">Translator</a> initializer:</p>
 
84
<pre class="py-doctest">
 
85
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">def</span> <span class="py-defname">pseudo_gettext</span>(string):
 
86
<span class="py-more">... </span>    return {
 
87
<span class="py-more">... </span>        <span class="py-string">'Example'</span>: <span class="py-string">'Beispiel'</span>,
 
88
<span class="py-more">... </span>        <span class="py-string">'Hello, %(name)s'</span>: <span class="py-string">'Hallo, %(name)s'</span>
 
89
<span class="py-more">... </span>    }[string]
 
90
<span class="py-prompt">&gt;&gt;&gt;</span>
 
91
<span class="py-prompt">&gt;&gt;&gt; </span>translator = Translator(pseudo_gettext)</pre>
 
92
<p>Next, the translator needs to be prepended to any already defined filters
 
93
on the template:</p>
 
94
<pre class="py-doctest">
 
95
<span class="py-prompt">&gt;&gt;&gt; </span>tmpl.filters.insert(0, translator)</pre>
 
96
<p>When generating the template output, our hard-coded translations should be
 
97
applied as expected:</p>
 
98
<pre class="py-doctest">
 
99
<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)
 
100
<span class="py-output">&lt;html&gt;</span>
 
101
<span class="py-output">  &lt;head&gt;</span>
 
102
<span class="py-output">    &lt;title&gt;Beispiel&lt;/title&gt;</span>
 
103
<span class="py-output">  &lt;/head&gt;</span>
 
104
<span class="py-output">  &lt;body&gt;</span>
 
105
<span class="py-output">    &lt;h1&gt;Beispiel&lt;/h1&gt;</span>
 
106
<span class="py-output">    &lt;p&gt;Hallo, Hans&lt;/p&gt;</span>
 
107
<span class="py-output">  &lt;/body&gt;</span>
 
108
<span class="py-output">&lt;/html&gt;</span></pre><br /><br />
 
109
 
 
110
<!-- ==================== INSTANCE METHODS ==================== -->
 
111
<a name="section-InstanceMethods"></a>
 
112
<table class="summary" border="1" cellpadding="3"
 
113
       cellspacing="0" width="100%" bgcolor="white">
 
114
<tr bgcolor="#70b0f0" class="table-header">
 
115
  <td align="left" colspan="2" class="table-header">
 
116
    <span class="table-header">Instance Methods</span></td>
 
117
</tr>
 
118
<tr>
 
119
    <td width="15%" align="right" valign="top" class="summary">
 
120
      <span class="summary-type">&nbsp;</span>
 
121
    </td><td class="summary">
 
122
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
 
123
        <tr>
 
124
          <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>,
 
125
        <span class="summary-sig-arg">translate</span>=<span class="summary-sig-default">&lt;function gettext at 0x110a0b0&gt;</span>,
 
126
        <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>,
 
127
        <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">alt</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></span>)</span><br />
 
128
      Initialize the translator.</td>
 
129
          <td align="right" valign="top">
 
130
            
 
131
            
 
132
          </td>
 
133
        </tr>
 
134
      </table>
 
135
      
 
136
    </td>
 
137
  </tr>
 
138
<tr>
 
139
    <td width="15%" align="right" valign="top" class="summary">
 
140
      <span class="summary-type">&nbsp;</span>
 
141
    </td><td class="summary">
 
142
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
 
143
        <tr>
 
144
          <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>,
 
145
        <span class="summary-sig-arg">stream</span>,
 
146
        <span class="summary-sig-arg">ctxt</span>=<span class="summary-sig-default">None</span>,
 
147
        <span class="summary-sig-arg">search_text</span>=<span class="summary-sig-default">True</span>)</span><br />
 
148
      Translate any localizable strings in the given stream.</td>
 
149
          <td align="right" valign="top">
 
150
            
 
151
            
 
152
          </td>
 
153
        </tr>
 
154
      </table>
 
155
      
 
156
    </td>
 
157
  </tr>
 
158
<tr>
 
159
    <td width="15%" align="right" valign="top" class="summary">
 
160
      <span class="summary-type">&nbsp;</span>
 
161
    </td><td class="summary">
 
162
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
 
163
        <tr>
 
164
          <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>,
 
165
        <span class="summary-sig-arg">stream</span>,
 
166
        <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><br />
 
167
      Extract localizable strings from the given template stream.</td>
 
168
          <td align="right" valign="top">
 
169
            
 
170
            
 
171
          </td>
 
172
        </tr>
 
173
      </table>
 
174
      
 
175
    </td>
 
176
  </tr>
 
177
  <tr>
 
178
    <td colspan="2" class="summary">
 
179
    <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
 
180
      <code>__delattr__</code>,
 
181
      <code>__getattribute__</code>,
 
182
      <code>__hash__</code>,
 
183
      <code>__new__</code>,
 
184
      <code>__reduce__</code>,
 
185
      <code>__reduce_ex__</code>,
 
186
      <code>__repr__</code>,
 
187
      <code>__setattr__</code>,
 
188
      <code>__str__</code>
 
189
      </p>
 
190
    </td>
 
191
  </tr>
 
192
</table>
 
193
<!-- ==================== CLASS VARIABLES ==================== -->
 
194
<a name="section-ClassVariables"></a>
 
195
<table class="summary" border="1" cellpadding="3"
 
196
       cellspacing="0" width="100%" bgcolor="white">
 
197
<tr bgcolor="#70b0f0" class="table-header">
 
198
  <td align="left" colspan="2" class="table-header">
 
199
    <span class="table-header">Class Variables</span></td>
 
200
</tr>
 
201
<tr>
 
202
    <td width="15%" align="right" valign="top" class="summary">
 
203
      <span class="summary-type">&nbsp;</span>
 
204
    </td><td class="summary">
 
205
        <a href="genshi.filters.i18n.Translator-class.html#IGNORE_TAGS" class="summary-name">IGNORE_TAGS</a> = <code title="frozenset([QName(u'script'),
 
206
           QName(u'style'),
 
207
           QName(u'http://www.w3.org/1999/xhtml}script'),
 
208
           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>
 
209
    </td>
 
210
  </tr>
 
211
<tr>
 
212
    <td width="15%" align="right" valign="top" class="summary">
 
213
      <span class="summary-type">&nbsp;</span>
 
214
    </td><td class="summary">
 
215
        <a name="INCLUDE_ATTRS"></a><span class="summary-name">INCLUDE_ATTRS</span> = <code title="frozenset(['alt', 'title'])"><code class="variable-group">frozenset([</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">title</code><code class="variable-quote">'</code><code class="variable-group">])</code></code>
 
216
    </td>
 
217
  </tr>
 
218
<tr>
 
219
    <td width="15%" align="right" valign="top" class="summary">
 
220
      <span class="summary-type">&nbsp;</span>
 
221
    </td><td class="summary">
 
222
        <a href="genshi.filters.i18n.Translator-class.html#GETTEXT_FUNCTIONS" class="summary-name">GETTEXT_FUNCTIONS</a> = <code title="('_',
 
223
 'gettext',
 
224
 'ngettext',
 
225
 'dgettext',
 
226
 'dngettext',
 
227
 'ugettext',
 
228
 '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>
 
229
    </td>
 
230
  </tr>
 
231
</table>
 
232
<!-- ==================== PROPERTIES ==================== -->
 
233
<a name="section-Properties"></a>
 
234
<table class="summary" border="1" cellpadding="3"
 
235
       cellspacing="0" width="100%" bgcolor="white">
 
236
<tr bgcolor="#70b0f0" class="table-header">
 
237
  <td align="left" colspan="2" class="table-header">
 
238
    <span class="table-header">Properties</span></td>
 
239
</tr>
 
240
  <tr>
 
241
    <td colspan="2" class="summary">
 
242
    <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>:
 
243
      <code>__class__</code>
 
244
      </p>
 
245
    </td>
 
246
  </tr>
 
247
</table>
 
248
<!-- ==================== METHOD DETAILS ==================== -->
 
249
<a name="section-MethodDetails"></a>
 
250
<table class="details" border="1" cellpadding="3"
 
251
       cellspacing="0" width="100%" bgcolor="white">
 
252
<tr bgcolor="#70b0f0" class="table-header">
 
253
  <td align="left" colspan="2" class="table-header">
 
254
    <span class="table-header">Method Details</span></td>
 
255
</tr>
 
256
</table>
 
257
<a name="__init__"></a>
 
258
<div>
 
259
<table class="details" border="1" cellpadding="3"
 
260
       cellspacing="0" width="100%" bgcolor="white">
 
261
<tr><td>
 
262
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
 
263
  <tr valign="top"><td>
 
264
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__init__</span>(<span class="sig-arg">self</span>,
 
265
        <span class="sig-arg">translate</span>=<span class="sig-default">&lt;function gettext at 0x110a0b0&gt;</span>,
 
266
        <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>,
 
267
        <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">alt</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></span>)</span>
 
268
    <br /><em class="fname">(Constructor)</em>
 
269
  </h3>
 
270
  </td><td align="right" valign="top"
 
271
    >&nbsp;
 
272
    </td>
 
273
  </table>
 
274
  
 
275
  Initialize the translator.
 
276
  <dl class="fields">
 
277
    <dt>Parameters:</dt>
 
278
    <dd><ul class="nomargin-top">
 
279
        <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
 
280
<tt class="rst-docutils literal"><span class="pre">ugettext</span></tt>.</li>
 
281
        <li><strong class="pname"><code>ignore_tags</code></strong> - a set of tag names that should not be localized</li>
 
282
        <li><strong class="pname"><code>include_attrs</code></strong> - a set of attribute names should be localized</li>
 
283
    </ul></dd>
 
284
    <dt>Overrides:
 
285
      object.__init__
 
286
    </dt>
 
287
  </dl>
 
288
</td></tr></table>
 
289
</div>
 
290
<a name="__call__"></a>
 
291
<div>
 
292
<table class="details" border="1" cellpadding="3"
 
293
       cellspacing="0" width="100%" bgcolor="white">
 
294
<tr><td>
 
295
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
 
296
  <tr valign="top"><td>
 
297
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__call__</span>(<span class="sig-arg">self</span>,
 
298
        <span class="sig-arg">stream</span>,
 
299
        <span class="sig-arg">ctxt</span>=<span class="sig-default">None</span>,
 
300
        <span class="sig-arg">search_text</span>=<span class="sig-default">True</span>)</span>
 
301
    <br /><em class="fname">(Call operator)</em>
 
302
  </h3>
 
303
  </td><td align="right" valign="top"
 
304
    >&nbsp;
 
305
    </td>
 
306
  </table>
 
307
  
 
308
  <p>Translate any localizable strings in the given stream.</p>
 
309
<p>This function shouldn't be called directly. Instead, an instance of
 
310
the <a href="genshi.filters.i18n.Translator-class.html" class="link">Translator</a> class should be registered as a filter with the
 
311
<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
 
312
filter. If used as a template filter, it should be inserted in front of
 
313
all the default filters.</p>
 
314
  <dl class="fields">
 
315
    <dt>Parameters:</dt>
 
316
    <dd><ul class="nomargin-top">
 
317
        <li><strong class="pname"><code>stream</code></strong> - the markup event stream</li>
 
318
        <li><strong class="pname"><code>ctxt</code></strong> - the template context (not used)</li>
 
319
        <li><strong class="pname"><code>search_text</code></strong> - whether text nodes should be translated (used
 
320
internally)</li>
 
321
    </ul></dd>
 
322
    <dt>Returns:</dt>
 
323
        <dd>the localized stream</dd>
 
324
  </dl>
 
325
</td></tr></table>
 
326
</div>
 
327
<a name="extract"></a>
 
328
<div>
 
329
<table class="details" border="1" cellpadding="3"
 
330
       cellspacing="0" width="100%" bgcolor="white">
 
331
<tr><td>
 
332
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
 
333
  <tr valign="top"><td>
 
334
  <h3 class="epydoc"><span class="sig"><span class="sig-name">extract</span>(<span class="sig-arg">self</span>,
 
335
        <span class="sig-arg">stream</span>,
 
336
        <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>
 
337
  </h3>
 
338
  </td><td align="right" valign="top"
 
339
    >&nbsp;
 
340
    </td>
 
341
  </table>
 
342
  
 
343
  <p>Extract localizable strings from the given template stream.</p>
 
344
<p>For every string found, this function yields a <tt class="rst-docutils literal"><span class="pre">(lineno,</span> <span class="pre">function,</span>
 
345
<span class="pre">message)</span></tt> tuple, where:</p>
 
346
<ul class="rst-simple">
 
347
<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>
 
348
<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
 
349
string was extracted from embedded Python code), and</li>
 
350
<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).</li>
 
351
</ul>
 
352
<pre class="py-doctest">
 
353
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">from</span> genshi.template <span class="py-keyword">import</span> MarkupTemplate
 
354
<span class="py-prompt">&gt;&gt;&gt;</span>
 
355
<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>
 
356
<span class="py-more">... </span><span class="py-string">  &lt;head&gt;</span>
 
357
<span class="py-more">... </span><span class="py-string">    &lt;title&gt;Example&lt;/title&gt;</span>
 
358
<span class="py-more">... </span><span class="py-string">  &lt;/head&gt;</span>
 
359
<span class="py-more">... </span><span class="py-string">  &lt;body&gt;</span>
 
360
<span class="py-more">... </span><span class="py-string">    &lt;h1&gt;Example&lt;/h1&gt;</span>
 
361
<span class="py-more">... </span><span class="py-string">    &lt;p&gt;${_(&quot;Hello, %(name)s&quot;) % dict(name=username)}&lt;/p&gt;</span>
 
362
<span class="py-more">... </span><span class="py-string">  &lt;/body&gt;</span>
 
363
<span class="py-more">... </span><span class="py-string">&lt;/html&gt;'''</span>, filename=<span class="py-string">'example.html'</span>)
 
364
<span class="py-prompt">&gt;&gt;&gt;</span>
 
365
<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):
 
366
<span class="py-more">... </span>   <span class="py-keyword">print</span> <span class="py-string">&quot;%d, %r, %r&quot;</span> % (lineno, funcname, message)
 
367
<span class="py-output">3, None, u'Example'</span>
 
368
<span class="py-output">6, None, u'Example'</span>
 
369
<span class="py-output">7, '_', u'Hello, %(name)s'</span></pre>
 
370
  <dl class="fields">
 
371
    <dt>Parameters:</dt>
 
372
    <dd><ul class="nomargin-top">
 
373
        <li><strong class="pname"><code>stream</code></strong> - the event stream to extract strings from; can be a
 
374
regular stream or a template stream</li>
 
375
        <li><strong class="pname"><code>gettext_functions</code></strong> - a sequence of function names that should be
 
376
treated as gettext-style localization
 
377
functions</li>
 
378
    </ul></dd>
 
379
  </dl>
 
380
</td></tr></table>
 
381
</div>
 
382
<br />
 
383
<!-- ==================== CLASS VARIABLE DETAILS ==================== -->
 
384
<a name="section-ClassVariableDetails"></a>
 
385
<table class="details" border="1" cellpadding="3"
 
386
       cellspacing="0" width="100%" bgcolor="white">
 
387
<tr bgcolor="#70b0f0" class="table-header">
 
388
  <td align="left" colspan="2" class="table-header">
 
389
    <span class="table-header">Class Variable Details</span></td>
 
390
</tr>
 
391
</table>
 
392
<a name="IGNORE_TAGS"></a>
 
393
<div>
 
394
<table class="details" border="1" cellpadding="3"
 
395
       cellspacing="0" width="100%" bgcolor="white">
 
396
<tr><td>
 
397
  <h3 class="epydoc">IGNORE_TAGS</h3>
 
398
  
 
399
  <dl class="fields">
 
400
  </dl>
 
401
  <dl class="fields">
 
402
    <dt>Value:</dt>
 
403
      <dd><table><tr><td><pre class="variable">
 
404
<code class="variable-group">frozenset([</code>QName(u'script')<code class="variable-op">,</code>
 
405
           QName(u'style')<code class="variable-op">,</code>
 
406
           QName(u'http://www.w3.org/1999/xhtml}script')<code class="variable-op">,</code>
 
407
           QName(u'http://www.w3.org/1999/xhtml}style')<code class="variable-group">])</code>
 
408
</pre></td></tr></table>
 
409
</dd>
 
410
  </dl>
 
411
</td></tr></table>
 
412
</div>
 
413
<a name="GETTEXT_FUNCTIONS"></a>
 
414
<div>
 
415
<table class="details" border="1" cellpadding="3"
 
416
       cellspacing="0" width="100%" bgcolor="white">
 
417
<tr><td>
 
418
  <h3 class="epydoc">GETTEXT_FUNCTIONS</h3>
 
419
  
 
420
  <dl class="fields">
 
421
  </dl>
 
422
  <dl class="fields">
 
423
    <dt>Value:</dt>
 
424
      <dd><table><tr><td><pre class="variable">
 
425
<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>
 
426
 <code class="variable-quote">'</code><code class="variable-string">gettext</code><code class="variable-quote">'</code><code class="variable-op">,</code>
 
427
 <code class="variable-quote">'</code><code class="variable-string">ngettext</code><code class="variable-quote">'</code><code class="variable-op">,</code>
 
428
 <code class="variable-quote">'</code><code class="variable-string">dgettext</code><code class="variable-quote">'</code><code class="variable-op">,</code>
 
429
 <code class="variable-quote">'</code><code class="variable-string">dngettext</code><code class="variable-quote">'</code><code class="variable-op">,</code>
 
430
 <code class="variable-quote">'</code><code class="variable-string">ugettext</code><code class="variable-quote">'</code><code class="variable-op">,</code>
 
431
 <code class="variable-quote">'</code><code class="variable-string">ungettext</code><code class="variable-quote">'</code><code class="variable-group">)</code>
 
432
</pre></td></tr></table>
 
433
</dd>
 
434
  </dl>
 
435
</td></tr></table>
 
436
</div>
 
437
<br />
 
438
<!-- ==================== NAVIGATION BAR ==================== -->
 
439
<table class="navbar" border="0" width="100%" cellpadding="0"
 
440
       bgcolor="#a0c0ff" cellspacing="0">
 
441
  <tr valign="middle">
 
442
  <!-- Home link -->
 
443
      <th>&nbsp;&nbsp;&nbsp;<a
 
444
        href="genshi-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>
 
445
 
 
446
  <!-- Tree link -->
 
447
      <th>&nbsp;&nbsp;&nbsp;<a
 
448
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
 
449
 
 
450
  <!-- Index link -->
 
451
      <th>&nbsp;&nbsp;&nbsp;<a
 
452
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>
 
453
 
 
454
  <!-- Help link -->
 
455
      <th>&nbsp;&nbsp;&nbsp;<a
 
456
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
 
457
 
 
458
  <!-- Project homepage -->
 
459
      <th class="navbar" align="right" width="100%">
 
460
        <table border="0" cellpadding="0" cellspacing="0">
 
461
          <tr><th class="navbar" align="center"
 
462
            ><a class="navbar" target="_top" href="../index.html">Documentation Index</a></th>
 
463
          </tr></table></th>
 
464
  </tr>
 
465
</table>
 
466
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
 
467
  <tr>
 
468
    <td align="left" class="footer">
 
469
    Generated by Epydoc 3.0beta1 on Mon Apr 16 16:02:13 2007
 
470
    </td>
 
471
    <td align="right" class="footer">
 
472
      <a href="http://epydoc.sourceforge.net">http://epydoc.sourceforge.net</a>
 
473
    </td>
 
474
  </tr>
 
475
</table>
 
476
 
 
477
<script type="text/javascript">
 
478
  <!--
 
479
  // Private objects are initially displayed (because if
 
480
  // javascript is turned off then we want them to be
 
481
  // visible); but by default, we want to hide them.  So hide
 
482
  // them unless we have a cookie that says to show them.
 
483
  checkCookie()
 
484
  // -->
 
485
</script>
 
486
  
 
487
</body>
 
488
</html>