@umbraco-cms/backoffice

    Class UmbLocalizationController<LocalizationSetType>

    The UmbLocalizationController enables localization for your element.

    UmbLocalizeElement

    import { UmbLocalizationController } from '@umbraco-cms/backoffice/localization-api';

    \@customElement('my-element')
    export class MyElement extends LitElement {
    private localize = new UmbLocalizationController(this);

    render() {
    return html`<p>${this.localize.term('general_close')}</p>`;
    }
    }

    Type Parameters

    Implements

    Index

    Constructors

    Properties

    controllerAlias: symbol = LocalizationControllerAlias

    Methods

    • Outputs a localized date in the specified format.

      Parameters

      • dateToFormat: string | Date

        the date to format.

      • Optionaloptions: DateTimeFormatOptions

        the options to use when formatting the date.

      Returns string

    • Outputs a localized compounded time in a duration format.

      Parameters

      • fromDate: string | Date

        the date to compare from.

      • OptionaltoDate: string | Date

        the date to compare to, usually the current date (default: current date).

      • Optionaloptions: any

        the options to use when formatting the time.

      Returns string

      • the formatted time, example: "2 days, 3 hours, 5 minutes"
      "2 days, 3 hours and 5 minutes"
      
    • Outputs a localized list of values in the specified format.

      Parameters

      • values: Iterable<string>

        the values to format.

      • Optionaloptions: ListFormatOptions

        the options to use when formatting the list.

      Returns string

      • the formatted list.
      "one, two, and three"
      
    • Outputs a localized number in the specified format.

      Parameters

      • numberToFormat: string | number

        the number or string to format.

      • Optionaloptions: NumberFormatOptions

        the options to use when formatting the number.

      Returns string

      • the formatted number.
    • Outputs a localized time in relative format.

      Parameters

      • value: number

        the value to format.

      • unit: RelativeTimeFormatUnit

        the unit of time to format.

      • Optionaloptions: RelativeTimeFormatOptions

        the options to use when formatting the time.

      Returns string

      • the formatted time.
      "in 2 days"
      
    • Translates a string containing one or more terms. The terms should be prefixed with a # character. If the term is found in the localization set, it will be replaced with the localized term. If the term is not found, the original term will be returned.

      Parameters

      • text: undefined | null | string

        The text to translate.

      • ...args: any

        The arguments to parse for this localization entry.

      Returns string

      The translated text.

    MMNEPVFCICPMFPCPTTAAATR