class LazyString
An object that encapsulates a string, evaluated only when needed.
class LazyString extends String
Description
This class is primarily used for string formatting and localization, usually as the result of a call to strf or to process string-formatted bindings.
Constructor
- constructor(get?)Creates a new lazily evaluated string instance.
Static Members
- LazyString.invalidateCache() staticInvalidates all string values cached by LazyString.cache().
- LazyString.setI18nInterface(i18n?) staticSets the current I18n provider.
- LazyString.local(value, …type) staticLocalizes a single value using the current I18n provider.
Instance Members
- toStringReturns a string value, i.e. the result of evaluating the encapsulated string.
- getFormatArgs()Returns the arguments that were (last) passed to
format
, or an empty array. - getOriginal()Returns the original (untranslated and unformatted) string or LazyString instance.
- cache()Caches the result after evaluating it once.
- translate()Translates the string using the current I18n provider.
- format(…args)Replaces placeholders in the string with string-formatted values.
Related
- function strf(format, …values)Returns a (lazily) formatted string incorporating the provided values.
- function strf(format, …bindings) staticCreates a new string-formatted binding, with nested property bindings.