Interface ITranslatorConnector

Translation connection interface.

interface ITranslatorConnector {
    fetch(): Promise<ILanguageList>;
    fetch(opts: { language: string }): Promise<Language>;
    list(
        query?: string,
    ): Promise<
        { ids: (undefined | { language: string })[]; values: Language[] },
    >;
    remove(id: undefined | { language: string }): Promise<any>;
    save(
        id: undefined | { language: string },
        value: Language | ILanguageList,
    ): Promise<any>;
}

Hierarchy (View Summary)

Implemented by

Methods

  • Retrieve the list of items available from the data connector.

    Parameters

    • Optionalquery: string

      The optional query filter to apply to the connector request.

    Returns Promise<{ ids: (undefined | { language: string })[]; values: Language[] }>

    A promise that bears a list of values and an associated list of fetch ids.

    The promise returned by this method may be rejected if an error occurs in retrieving the data. The two lists will always be the same size. If there is no data, this method will succeed with empty ids and values.

  • Remove a value using the data connector.

    Parameters

    • id: undefined | { language: string }

      The identifier for the data being removed.

    Returns Promise<any>

    A promise that is rejected if remove fails and succeeds otherwise.

    This promise may resolve with a back-end response or undefined. Existence of resolved content in the promise is not prescribed and must be tested for. For example, some back-ends may return a copy of the item of type T being removed while others may return no content.

  • Save a value using the data connector.

    Parameters

    • id: undefined | { language: string }

      The identifier for the data being saved.

    • value: Language | ILanguageList

      The data being saved.

    Returns Promise<any>

    A promise that is rejected if saving fails and succeeds otherwise.

    This promise may resolve with a back-end response or undefined. Existence of resolved content in the promise is not prescribed and must be tested for. For example, some back-ends may return a copy of the item of type T being saved while others may return no content.