Skip to main content

localize

Check if value is a localizable type (date, number...) and return it formatted as a string using current locale format.

If use_l10n is provided and is not None, it forces the value to
be localized (or not), otherwise it's always localized.
def localize(
value: Any,
use_l10n: boolean = None
) - > string

Check if value is a localizable type (date, number...) and return it formatted as a string using current locale format. If use_l10n is provided and is not None, it forces the value to be localized (or not), otherwise it's always localized.

Parameters

NameTypeDescription
valueAnyThe object to be formatted, such as a date, time, number, or string.
use_l10nboolean = NoneA flag to explicitly enable or disable localization; if None, the default localization behavior is used.

Returns

TypeDescription
stringThe value formatted as a string according to the current locale settings, or the original value if it is not a localizable type.