Reports the approximate distance in time between two time representations.
The initial time.
The ending time. Defaults to Date.now()
.
The options.
The distance in time representation.
Set if engine should fallback to the default locale when a translation is
missing. Defaults to false
.
When enabled, missing translations will first be looked for in less
specific versions of the requested locale and if that fails by taking them
from your I18n#defaultLocale
.
Localize several values.
You can provide the following scopes: currency
, number
, or
percentage
. If you provide a scope that matches the /^(date|time)/
regular expression then the value
will be converted by using the
I18n.toTime
function. It will default to the value's toString
function.
If value is either null
or undefined
then an empty string will be
returned, regardless of that localization type has been used.
The localization type.
The value that must be localized.
The localization options.
The localized string.
The locale resolver registry.
Set missing translation behavior.
message
will display a message that the translation is missing.guess
will try to guess the string.error
will raise an exception whenever a translation is not defined.See MissingTranslation.register for instructions on how to define your own behavior.
Return a missing placeholder message for given parameters.
The missing translation behavior registry.
If you use missingBehavior with 'message', but want to know that the string is actually missing for testing purposes, you can prefix the guessed string by setting the value here. By default, no prefix is used.
Return a placeholder message for null values. Defaults to the same behavior
as I18n.missingPlaceholder
.
List of all onChange handlers.
Pluralize the given scope using the count
value. The pluralized
translation may have other placeholders, which will be retrieved from
options
.
The counting number.
The translation scope.
The translation options.
The translated string.
Set the placeholder format. Accepts {{placeholder}}
and %{placeholder}
.
The pluralization behavior registry.
Translate the given scope with the provided options.
The scope that will be used.
The options that will be used on the
translation. Can include some special options like defaultValue
, count
,
and scope
. Everything else will be treated as replacement values.
The translated string.
Transform keys. By default, it returns the key as it is, but allows for overriding. For instance, you can set a function to receive the camelcase key, and convert it to snake case.
Set the registered translations. The root key must always be the locale (and its variations with region).
Remember that no events will be triggered if you change this object
directly. To trigger onchange
events, you must perform updates either
using I18n#store
or I18n#update
.
Return the default locale, using a explicit locale set using
i18n.defaultLocale = locale
, the default locale set using
i18n.defaultLocale
or the fallback, which is en
.
The current locale.
Set the default locale explicitly.
The new locale.
The current locale.
Return the current locale, using a explicit locale set using
i18n.locale = newLocale
, the default locale set using
i18n.defaultLocale
or the fallback, which is en
.
The current locale.
Set the current locale explicitly.
The new locale.
The current locale.
Return the change version. This value is incremented whenever I18n#store
or I18n#update
is called, or when I18n#locale
/I18n#defaultLocale
is
set.
Localize several values.
You can provide the following scopes: currency
, number
, or
percentage
. If you provide a scope that matches the /^(date|time)/
regular expression then the value
will be converted by using the
I18n.toTime
function. It will default to the value's toString
function.
If value is either null
or undefined
then an empty string will be
returned, regardless of that localization type has been used.
The localization type.
The value that must be localized.
The localization options.
The localized string.
Formats a number
into a currency string (e.g., $13.65). You can customize
the format in the using an options
object.
The currency unit and number formatting of the current locale will be used unless otherwise specified in the provided options. No currency conversion is performed. If the user is given a way to change their locale, they will also be able to change the relative value of the currency displayed with this helper.
The number to be formatted.
The formatting options. When
defined, supersedes the default options defined by number.format
and
number.currency.*
.
The formatted number.
Formats a +number+ with grouped thousands using delimiter
(e.g., 12,324).
You can customize the format in the options
parameter.
The numeric value that will be formatted.
The formatting options.
The formatted number.
Convert a number into a readable representation.
The number that will be formatted.
The formatting options. When
defined, supersedes the default options stored at number.human.format.*
and number.human.storage_units.*
.
The formatted number.
Convert a number into a readable size representation.
The number that will be formatted.
The formatting options. When
defined, supersedes the default options stored at
number.human.storage_units.*
and number.human.format
.
The formatted number.
Convert a number into a formatted percentage value.
The number to be formatted.
The formatting options. When
defined, supersedes the default options stored at number.format
and
number.percentage.*
.
The formatted number.
Convert number to a formatted rounded value.
The number to be formatted.
The formatting options.
The formatted number.
Add a callback that will be executed whenever locale/defaultLocale changes,
or I18n#store
/ I18n#update
is called.
The callback that will be executed.
Pluralize the given scope using the count
value. The pluralized
translation may have other placeholders, which will be retrieved from
options
.
The counting number.
The translation scope.
The translation options.
The translated string.
Update translations by merging them. Newest translations will override existing ones.
An object containing the translations that will be merged into existing translations.
Formats time according to the directives in the given format string.
The directives begins with a percent (%
) character. Any text not listed
as a directive will be passed through to the output string.
The date that will be formatted.
The formatting string.
The formatting options.
The formatted date.
Reports the approximate distance in time between two time representations.
The initial time.
The ending time. Defaults to Date.now()
.
The options.
The distance in time representation.
Converts the array to a comma-separated sentence where the last element is joined by the connector word.
The list of items that will be joined.
The options.
The joined string.
Translate the given scope with the provided options.
The scope that will be used.
The options that will be used on the
translation. Can include some special options like defaultValue
, count
,
and scope
. Everything else will be treated as replacement values.
The translated string.
You may want to update a part of your translations. This is a public interface for doing it so.
If the provided path exists, it'll be replaced. Otherwise, a new node will be created. When running in strict mode, paths that doesn't already exist will raise an exception.
Strict mode will also raise an exception if the override type differs from previous node type.
The path that's going to be updated. It must
include the language, as in en.messages
.
The new translation node.
Set options.
Raise an exception if path doesn't already exist, or if previous node's type differs from new node's type.
Executes function with given locale set. The locale will be changed only
during the callback
's execution, switching back to the previous value
once it finishes (with or without errors).
This is an asynchronous call, which means you must use await
or you may
end up with a race condition.
The temporary locale that will be set during the function's execution.
The function that will be executed with a temporary locale set.
Generated using TypeDoc
Set the default string separator. Defaults to
.
, as inscope.translation
.