Current File : //usr/share/doc/python-babel-0.9.6/doc/api/babel.messages.plurals-module.html |
<?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>babel.messages.plurals</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> <a
href="babel-module.html">Home</a> </th>
<!-- Tree link -->
<th> <a
href="module-tree.html">Trees</a> </th>
<!-- Index link -->
<th> <a
href="identifier-index.html">Indices</a> </th>
<!-- Help link -->
<th> <a
href="help.html">Help</a> </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="babel-module.html">Package babel</a> ::
<a href="babel.messages-module.html">Package messages</a> ::
Module plurals
</span>
</td>
<td>
<table cellpadding="0" cellspacing="0">
<!-- hide/show private -->
</table>
</td>
</tr>
</table>
<!-- ==================== MODULE DESCRIPTION ==================== -->
<h1 class="epydoc">Module plurals</h1><p class="nomargin-top"></p>
Plural form definitions.
<!-- ==================== FUNCTIONS ==================== -->
<a name="section-Functions"></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">Functions</span></td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="babel.messages.plurals-module.html#get_plural" class="summary-sig-name">get_plural</a>(<span class="summary-sig-arg">locale</span>=<span class="summary-sig-default"><code class="variable-quote">'</code><code class="variable-string">de_DE</code><code class="variable-quote">'</code></span>)</span><br />
A tuple with the information catalogs need to perform proper
pluralization.</td>
<td align="right" valign="top">
</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- ==================== VARIABLES ==================== -->
<a name="section-Variables"></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">Variables</span></td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="LC_CTYPE"></a><span class="summary-name">LC_CTYPE</span> = <code title="'de_DE'"><code class="variable-quote">'</code><code class="variable-string">de_DE</code><code class="variable-quote">'</code></code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="babel.messages.plurals-module.html#PLURALS" class="summary-name">PLURALS</a> = <code title="{'af': (2, '(n != 1)'),
'ar': (6,
'(n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n>=3 && n<=10 ? 3 : n>=11 &\
& n<=99 ? 4 : 5)'),
'bg': (2, '(n != 1)'),
'bn': (2, '(n != 1)'),
'bo': (1, '0'),
'ca': (2, '(n != 1)'),
..."><code class="variable-group">{</code><code class="variable-quote">'</code><code class="variable-string">af</code><code class="variable-quote">'</code><code class="variable-op">: </code><code class="variable-group">(</code>2<code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">(n != 1)</code><code class="variable-quote">'</code><code class="variable-group">)</code><code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">ar</code><code class="variable-quote">'</code><code class="variable-op">: </code><code class="variable-group">(</code>6<code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">(n==0 ? 0 : n==1 </code><code class="variable-ellipsis">...</code></code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="DEFAULT_PLURAL"></a><span class="summary-name">DEFAULT_PLURAL</span> = <code title="(2, '(n != 1)')"><code class="variable-group">(</code>2<code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">(n != 1)</code><code class="variable-quote">'</code><code class="variable-group">)</code></code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="__package__"></a><span class="summary-name">__package__</span> = <code title="'babel.messages'"><code class="variable-quote">'</code><code class="variable-string">babel.messages</code><code class="variable-quote">'</code></code>
</td>
</tr>
</table>
<!-- ==================== FUNCTION DETAILS ==================== -->
<a name="section-FunctionDetails"></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">Function Details</span></td>
</tr>
</table>
<a name="get_plural"></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">get_plural</span>(<span class="sig-arg">locale</span>=<span class="sig-default"><code class="variable-quote">'</code><code class="variable-string">de_DE</code><code class="variable-quote">'</code></span>)</span>
</h3>
</td><td align="right" valign="top"
>
</td>
</tr></table>
<p>A tuple with the information catalogs need to perform proper
pluralization. The first item of the tuple is the number of plural
forms, the second the plural expression.</p>
<pre class="py-doctest">
<span class="py-prompt">>>> </span>get_plural(locale=<span class="py-string">'en'</span>)
<span class="py-output">(2, '(n != 1)')</span>
<span class="py-output"></span><span class="py-prompt">>>> </span>get_plural(locale=<span class="py-string">'ga'</span>)
<span class="py-output">(3, '(n==1 ? 0 : n==2 ? 1 : 2)')</span></pre>
<p>The object returned is a special tuple with additional members:</p>
<pre class="py-doctest">
<span class="py-prompt">>>> </span>tup = get_plural(<span class="py-string">"ja"</span>)
<span class="py-prompt">>>> </span>tup.num_plurals
<span class="py-output">1</span>
<span class="py-output"></span><span class="py-prompt">>>> </span>tup.plural_expr
<span class="py-output">'0'</span>
<span class="py-output"></span><span class="py-prompt">>>> </span>tup.plural_forms
<span class="py-output">'npurals=1; plural=0'</span></pre>
<p>Converting the tuple into a string prints the plural forms for a
gettext catalog:</p>
<pre class="py-doctest">
<span class="py-prompt">>>> </span>str(tup)
<span class="py-output">'npurals=1; plural=0'</span></pre>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<br />
<!-- ==================== VARIABLES DETAILS ==================== -->
<a name="section-VariablesDetails"></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">Variables Details</span></td>
</tr>
</table>
<a name="PLURALS"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<h3 class="epydoc">PLURALS</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">af</code><code class="variable-quote">'</code><code class="variable-op">: </code><code class="variable-group">(</code>2<code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">(n != 1)</code><code class="variable-quote">'</code><code class="variable-group">)</code><code class="variable-op">,</code>
<code class="variable-quote">'</code><code class="variable-string">ar</code><code class="variable-quote">'</code><code class="variable-op">: </code><code class="variable-group">(</code>6<code class="variable-op">,</code>
<code class="variable-quote">'</code><code class="variable-string">(n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n>=3 && n<=10 ? 3 : n>=11 &</code><span class="variable-linewrap"><img src="crarr.png" alt="\" /></span>
<code class="variable-string">& n<=99 ? 4 : 5)</code><code class="variable-quote">'</code><code class="variable-group">)</code><code class="variable-op">,</code>
<code class="variable-quote">'</code><code class="variable-string">bg</code><code class="variable-quote">'</code><code class="variable-op">: </code><code class="variable-group">(</code>2<code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">(n != 1)</code><code class="variable-quote">'</code><code class="variable-group">)</code><code class="variable-op">,</code>
<code class="variable-quote">'</code><code class="variable-string">bn</code><code class="variable-quote">'</code><code class="variable-op">: </code><code class="variable-group">(</code>2<code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">(n != 1)</code><code class="variable-quote">'</code><code class="variable-group">)</code><code class="variable-op">,</code>
<code class="variable-quote">'</code><code class="variable-string">bo</code><code class="variable-quote">'</code><code class="variable-op">: </code><code class="variable-group">(</code>1<code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">0</code><code class="variable-quote">'</code><code class="variable-group">)</code><code class="variable-op">,</code>
<code class="variable-quote">'</code><code class="variable-string">ca</code><code class="variable-quote">'</code><code class="variable-op">: </code><code class="variable-group">(</code>2<code class="variable-op">, </code><code class="variable-quote">'</code><code class="variable-string">(n != 1)</code><code class="variable-quote">'</code><code class="variable-group">)</code><code class="variable-op">,</code>
<code class="variable-ellipsis">...</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> <a
href="babel-module.html">Home</a> </th>
<!-- Tree link -->
<th> <a
href="module-tree.html">Trees</a> </th>
<!-- Index link -->
<th> <a
href="identifier-index.html">Indices</a> </th>
<!-- Help link -->
<th> <a
href="help.html">Help</a> </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 Thu Mar 17 15:12:44 2011
</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>