Translate class for handling text translation and transformation.

Constructors

Properties

Accessors

Methods

Constructors

  • Constructs a new instance of the Translator class.

    Parameters

    • Optionallocale: Locale = {}

      An object representing the initial locale configuration.

    • Optionaltransform: ((str: string) => string)

      A function for transforming strings.

        • (str): string
        • Parameters

          • str: string

          Returns string

    • Optionalconfig: Partial<ITranslateConfig> = {}

      An object representing additional configuration options.

    Returns Translate

Properties

config: Partial<ITranslateConfig> = {}

An object representing additional configuration options.

createElement: ((type: string, props: null | IAttributeCollection, ...children: any[]) => ReactElement<{}, string | JSXElementConstructor<any>>)

Creates and returns an element based on the provided type, props, and children.

Type declaration

    • (type, props, ...children): ReactElement<{}, string | JSXElementConstructor<any>>
    • Parameters

      • type: string

        The type of the element to create.

      • props: null | IAttributeCollection

        The properties or attributes to assign to the element.

      • Rest...children: any[]

        The child elements or content to append to the element.

      Returns ReactElement<{}, string | JSXElementConstructor<any>>

      • The created element.
translateText: ((text: string) => string)

Translates the given text to another language.

Type declaration

    • (text): string
    • Parameters

      • text: string

        The text to be translated.

      Returns string

      The translated text.

Accessors

  • get skipList(): string[]
  • Returns string[]

Methods

  • Clear the _skip and _transformed variables.

    Returns void

  • Create an element using the given type and props

    Parameters

    • type: string

      The type of the element

    • props: null | IAttributeCollection

      The props for the element

    Returns ReactElement<{}, string | JSXElementConstructor<any>>

    • The created element
  • Adds a middleware to the list of used middlewares.

    Parameters

    • middleware: Middleware

      The middleware to be added.

    Returns void

  • Installs the Translate object and configures React.

    Parameters

    • Rest...params: [locale: Locale, transform?: ((str: string) => string), config: Partial<ITranslateConfig>]

      The parameters needed to create a new Translate instance.

    Returns Translate

    The installed Translate object.