A class to help with localization of your bot. This handles string translation from the context of the guild. For more information, check Localizer.

Hierarchy

  • GuildLocalizer

Constructors

Properties

dataProviderKey: string

The key to be used to save the guild's locale in the client's data provider.

Default

locale

Memberof

GuildLocalizer

guild: Guild

The guild that corresponds to this guild localizer.

Memberof

GuildLocalizer

locale: string

The current locale set for the guild. Do not update this value manually, instead use the updateLocale() method.

Memberof

GuildLocalizer

localizer: Localizer

The main localizer for this guild localizer.

Memberof

GuildLocalizer

Methods

  • Initializes this guild localizer. You should call this after initializing the client's data provider since this method will read the locale set for each guild and will initialize their localizer with that value.

    Returns Promise<string>

    A promise that resolves to the locale set for this guild localizer.

    Throws

    Rejects if a guild localizer was being initialized with an unsupported locale retrieved from the data provider. This may happen if the locale saved in the data provider was updated manually.

  • Alias for translate().

    Parameters

    • key: string

      The key of the message to translate.

    • values: {} = {}

      The dynamic values to be replaced in the message.

      Returns string

      The translated message.

      Throws

      Throws if the key does not resolve to any message.

      Throws

      Throws if the given locale is not supported.

    • Get the message for the given key translated into the locale of this guild localizer. You can also supply an object containing the dynamic values to be used.

      Parameters

      • key: string

        The key of the message to translate.

      • values: {} = {}

        The dynamic values to be replaced in the message.

        Returns string

        The translated message.

        Throws

        Throws if the key does not resolve to any message.

        Throws

        Throws if the given locale is not supported.

      • Updates the locale set to this guild localizer. If the client has a data provider, it will also update the locale in it for persistence.

        Parameters

        • locale: string

          The new locale to be used by this guild localizer.

        Returns Promise<void>

        A promise that resolves once the locale has been updated.

        Throws

        Rejects if the given locale is not supported.

      Generated using TypeDoc