comparison babel/numbers.py @ 437:64155e929c84 trunk

Revert part of the commits with relation to the de locale's use of \xa0 as thousands separator, this is still a proposed change and not the active one.
author jruigrok
date Sat, 22 Aug 2009 12:09:29 +0000
parents 2a51e91bcfae
children ac8961d40e61 c76f397343d7
comparison
equal deleted inserted replaced
436:53d32919ed65 437:64155e929c84
131 u"""Return the given number formatted for a specific locale. 131 u"""Return the given number formatted for a specific locale.
132 132
133 >>> format_number(1099, locale='en_US') 133 >>> format_number(1099, locale='en_US')
134 u'1,099' 134 u'1,099'
135 >>> format_number(1099, locale='de_DE') 135 >>> format_number(1099, locale='de_DE')
136 u'1\\xa0099' 136 u'1.099'
137 137
138 138
139 :param number: the number to format 139 :param number: the number to format
140 :param locale: the `Locale` object or locale identifier 140 :param locale: the `Locale` object or locale identifier
141 :return: the formatted number 141 :return: the formatted number
153 u'1.235' 153 u'1.235'
154 >>> format_decimal(-1.2346, locale='en_US') 154 >>> format_decimal(-1.2346, locale='en_US')
155 u'-1.235' 155 u'-1.235'
156 >>> format_decimal(1.2345, locale='sv_SE') 156 >>> format_decimal(1.2345, locale='sv_SE')
157 u'1,234' 157 u'1,234'
158 >>> format_decimal(12345, locale='de') 158 >>> format_decimal(1.2345, locale='de')
159 u'12\\xa0345' 159 u'1,234'
160 160
161 The appropriate thousands grouping and the decimal separator are used for 161 The appropriate thousands grouping and the decimal separator are used for
162 each locale: 162 each locale:
163 163
164 >>> format_decimal(12345.5, locale='en_US') 164 >>> format_decimal(12345.5, locale='en_US')
182 >>> format_currency(1099.98, 'USD', locale='en_US') 182 >>> format_currency(1099.98, 'USD', locale='en_US')
183 u'$1,099.98' 183 u'$1,099.98'
184 >>> format_currency(1099.98, 'USD', locale='es_CO') 184 >>> format_currency(1099.98, 'USD', locale='es_CO')
185 u'US$\\xa01.099,98' 185 u'US$\\xa01.099,98'
186 >>> format_currency(1099.98, 'EUR', locale='de_DE') 186 >>> format_currency(1099.98, 'EUR', locale='de_DE')
187 u'1\\xa0099,98\\xa0\\u20ac' 187 u'1.099,98\\xa0\\u20ac'
188 188
189 The pattern can also be specified explicitly: 189 The pattern can also be specified explicitly:
190 190
191 >>> format_currency(1099.98, 'EUR', u'\xa4\xa4 #,##0.00', locale='en_US') 191 >>> format_currency(1099.98, 'EUR', u'\xa4\xa4 #,##0.00', locale='en_US')
192 u'EUR 1,099.98' 192 u'EUR 1,099.98'
Copyright (C) 2012-2017 Edgewall Software