Skip to content

API reference / @localizer/translate / dictionary

Function: dictionary()
experimental

dictionary<T>(dict): { readonly [P in string | number | symbol]: T[P] extends (value: V) => TranslationMap ? ValueFormatter<V> : Localizable }

Defined in: dictionary.ts:36

Creates a dictionary of localized values or value formatters.

This function takes a dictionary object (dict) where each key maps to either a static translation map or a function that generates a dynamic translation map. It returns a new dictionary where each key maps to either a Localizable value or a ValueFormatter, depending on the type of the input value.

Type Parameters

Type ParameterDescription
TThe type of the input dictionary.

Parameters

ParameterTypeDescription
dictTThe input dictionary containing static or dynamic translation maps.

Returns

{ readonly [P in string | number | symbol]: T[P] extends (value: V) => TranslationMap ? ValueFormatter<V> : Localizable }

A dictionary where each key maps to a localized value or a value formatter.