Class
zope.i18n.locales.LocaleNumbers

Implementation of ILocaleCurrency including inheritance support.

Examples:

>>> numbers = LocaleNumbers()
>>> numbers.symbols = {
...     'decimal': ',', 'group': '.', 'list': ';', 'percentSign': '%',
...     'nativeZeroDigit': '0', 'patternDigit': '#', 'plusSign': '+',
...     'minusSign': '-', 'exponential': 'E', 'perMille': 'o/oo',
...     'infinity': 'oo', 'nan': 'N/A'}

Setting up and accessing totally unnamed decimal format (very common scenario):

>>> length = LocaleFormatLength()
>>> format = LocaleFormat()
>>> format.pattern = u'#,##0.###;-#,##0.###'
>>> length.formats = {None: format}
>>> numbers.decimalFormats = {None: length}
>>> formatter = numbers.getFormatter('decimal')
>>> formatter.format(3.4)
u'3,4'
>>> formatter.format(-3.4567)
u'-3,457'
>>> formatter.format(3210.4)
u'3.210,4'

Setting up and accessing scientific formats with named format lengths:

>>> longlength = LocaleFormatLength('long')
>>> format = LocaleFormat()
>>> format.pattern = u'0.000###E+00'
>>> longlength.formats = {None: format}
>>> mediumlength = LocaleFormatLength('long')
>>> format = LocaleFormat()
>>> format.pattern = u'0.00##E+00'
>>> mediumlength.formats = {None: format}
>>> numbers.scientificFormats = {'long': longlength,
...                              'medium': mediumlength}
>>> numbers.defaultScientificFormat = 'long'
>>> formatter = numbers.getFormatter('scientific')
>>> formatter.format(1234.5678)
u'1,234568E+03'
>>> formatter = numbers.getFormatter('scientific', 'medium')
>>> formatter.format(1234.5678)
u'1,2346E+03'

Setting up and accessing percent formats with named format lengths and format names:

>>> longlength = LocaleFormatLength('long')
>>> fooformat = LocaleFormat()
>>> fooformat.pattern = u'0.##0%'
>>> barformat = LocaleFormat()
>>> barformat.pattern = u'0%'
>>> longlength.formats = {None: fooformat, 'bar': barformat}
>>> numbers.percentFormats = {'long': longlength}
>>> numbers.defaultPercentFormat = 'long'
>>> formatter = numbers.getFormatter('percent')
>>> formatter.format(123.45678)
u'123,457%'
>>> formatter = numbers.getFormatter('percent', name='bar')
>>> formatter.format(123.45678)
u'123%'

...using a default name:

>>> numbers.percentFormats['long'].default = 'bar'
>>> formatter = numbers.getFormatter('percent')
>>> formatter.format(123.45678)
u'123%'

Base classes

Implemented Interfaces

Attributes/Properties

There are no attributes in this class.

Methods

Known Subclasses

There are no known subclasses.