DictionaryTranslationOptions
API Reference for the DictionaryTranslationOptions type
Overview
The DictionaryTranslationOptions
type is used to pass variables to dictionary entries and specify their render behavior.
It is used with useDict()
to pass variables to dictionary entries.
Buildtime Translation:
useDict()
translations occur at buildtime; however, variables are never translated.
Instead, they are inserted into the translation with formatting.
Make sure to follow the deployment guide here.
Reference
Parameters
Prop | Type | Default |
---|---|---|
variables? | Record<string, any> | undefined |
variablesOptions? | Record<string, Intl.NumberFormatOptions | Intl.DateTimeFormatOptions> | undefined |
Description
Prop | Description |
---|---|
variables | An object where the keys identify where each value is mapped to in the dictionary entry. |
variablesOptions | An object where the keys identify the variable and the values define the variables behavior. See Intl.NumberFormatOptions and Intl.DateTimeFormatOptions for more information. |
Examples
Passing variables
In order to pass a variable to the dictionary entry, we need to do two things: (1) add a variable to the entry and (2) reference said variable in the d()
invocation.
First, we add a variable to the dictionary entry with the following syntax: {username}
.
username
is the name of the variable.
Next, we reference the variable:
Adding variable options
Variable options allow you to customize how a variable is rendered.
It uses the same syntax as the variables
object.
Next, we reference the variable:
Notes
- The
variables
object passes values to a dictionary entry. - The
variablesOptions
object defines the behavior of the variables.
Next steps
- See dictionaries for more information on dictionaries and common practices.
- See
useDict()
for more information on dictionaries interface. - See
Intl.NumberFormatOptions
andIntl.DateTimeFormatOptions
for more information on formatting options.