@@ -134,6 +134,67 @@ u'Donnerstag, 5. M\xe4rz 1987 17:12'
134134
135135For more format examples head over to the `babel `_ documentation.
136136
137+ Formatting Numbers
138+ ----------------
139+
140+ To format numbers you can use the :func: `format_number `,
141+ :func: `format_decimal `, :func: `format_currency `, :func: `format_percent ` and :func: `format_scientific `
142+ functions.
143+
144+ To play with the date formatting from the console, you can use the
145+ :meth: `~flask.Flask.test_request_context ` method:
146+
147+ >>> app.test_request_context().push()
148+
149+ Here some examples:
150+
151+ >>> from flask_babel import format_number
152+ >>> # format_number(number)
153+ >>> format_number(1099 )
154+ '1,099'
155+
156+ >>> from flask_babel import format_decimal
157+ >>> # format_decimal(number, format=None)
158+ >>> format_decimal(1.2346 )
159+ u'1.235'
160+
161+ >>> from flask_babel import format_currency
162+ >>> # format_currency(number, currency, format=None, currency_digits=True, format_type='standard')
163+ >>> format_currency(1099.98 , ' USD' )
164+ '$1,099.98'
165+
166+ >>> from flask_babel import format_percent
167+ >>> # format_percent(number, format=None)
168+ >>> format_percent(0.34 )
169+ '34%'
170+
171+ >>> from flask_babel import format_scientific
172+ >>> # format_scientific(number, format=None)
173+ >>> format_scientific(10000 )
174+ '1E4'
175+
176+ And again with a different language:
177+
178+ >>> app.config[' BABEL_DEFAULT_LOCALE' ] = ' de'
179+ >>> from flask_babel import refresh; refresh()
180+
181+ >>> format_number(1099 )
182+ '1.099'
183+
184+ >>> format_decimal(1.2346 )
185+ '1,235'
186+
187+ >>> format_currency(1099.98 , ' USD' )
188+ '1.099,98\xa0$'
189+
190+ >>> format_percent(0.34 )
191+ '34\xa0%'
192+
193+ >>> format_scientific(10000 )
194+ '1E4'
195+
196+ For more format examples head over to the `babel `_ documentation.
197+
137198Using Translations
138199------------------
139200
@@ -276,6 +337,19 @@ Datetime Functions
276337
277338.. autofunction :: format_timedelta
278339
340+ Number Functions
341+ ``````````````````
342+
343+ .. autofunction :: format_number
344+
345+ .. autofunction :: format_decimal
346+
347+ .. autofunction :: format_currency
348+
349+ .. autofunction :: format_percent
350+
351+ .. autofunction :: format_scientific
352+
279353Gettext Functions
280354`````````````````
281355
0 commit comments