Skip to content

API reference / @localizer/format / autoFormat

Function: autoFormat()

autoFormat(value): Localizable

Defined in: fn/autoFormat.ts:124

Formats a value into a Localizable object based on its type. By default, it uses the following formatters:

  • Numbers and bigints: formatted with decimal.
  • Number objects: formatted using their primitive value.
  • Date objects: formatted with date.
  • Arrays: recursively formatted into a localized list.
  • Localizable values: returned as-is.
  • undefined: represented as Empty.
  • Others: converted to a localized string with stringify.

Parameters

ParameterTypeDescription
valueunknownThe value to format.

Returns

Localizable

A Localizable object.