Qucs-S S-parameter Viewer & RF Synthesis Tools
Loading...
Searching...
No Matches
Classes | Functions | Variables
babel.messages.plurals Namespace Reference

Classes

class  _PluralTuple
 

Functions

_PluralTuple get_plural (Locale|str|None locale=None)
 

Variables

str LC_CTYPE = default_locale('LC_CTYPE')
 
dict PLURALS
 
tuple DEFAULT_PLURAL = (2, '(n != 1)')
 

Detailed Description

    babel.messages.plurals
    ~~~~~~~~~~~~~~~~~~~~~~

    Plural form definitions.

    :copyright: (c) 2013-2025 by the Babel Team.
    :license: BSD, see LICENSE for more details.

Function Documentation

◆ get_plural()

_PluralTuple babel.messages.plurals.get_plural ( Locale | str | None   locale = None)
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.

:param locale: the `Locale` object or locale identifier. Defaults to the system character type locale.

>>> get_plural(locale='en')
(2, '(n != 1)')
>>> get_plural(locale='ga')
(5, '(n==1 ? 0 : n==2 ? 1 : n>=3 && n<=6 ? 2 : n>=7 && n<=10 ? 3 : 4)')

The object returned is a special tuple with additional members:

>>> tup = get_plural("ja")
>>> tup.num_plurals
1
>>> tup.plural_expr
'0'
>>> tup.plural_forms
'nplurals=1; plural=0;'

Converting the tuple into a string prints the plural forms for a
gettext catalog:

>>> str(tup)
'nplurals=1; plural=0;'