MCPcopy
hub / github.com/django/django / number_format

Function number_format

django/utils/formats.py:172–190  ·  view source on GitHub ↗

Format a numeric value using localization settings. If use_l10n is provided and is not None, it forces the value to be localized (or not), otherwise it's always localized.

(value, decimal_pos=None, use_l10n=None, force_grouping=False)

Source from the content-addressed store, hash-verified

170
171
172def number_format(value, decimal_pos=None, use_l10n=None, force_grouping=False):
173 """
174 Format a numeric value using localization settings.
175
176 If use_l10n is provided and is not None, it forces the value to
177 be localized (or not), otherwise it's always localized.
178 """
179 if use_l10n is None:
180 use_l10n = True
181 lang = get_language() if use_l10n else None
182 return numberformat.format(
183 value,
184 get_format("DECIMAL_SEPARATOR", lang, use_l10n=use_l10n),
185 decimal_pos,
186 get_format("NUMBER_GROUPING", lang, use_l10n=use_l10n),
187 get_format("THOUSAND_SEPARATOR", lang, use_l10n=use_l10n),
188 force_grouping=force_grouping,
189 use_l10n=use_l10n,
190 )
191
192
193def localize(value, use_l10n=None):

Callers 3

intcommaFunction · 0.90
localizeFunction · 0.85
localize_inputFunction · 0.85

Calls 3

get_languageFunction · 0.90
get_formatFunction · 0.85
formatMethod · 0.45

Tested by

no test coverage detected