@mathjax/src
    Preparing search index...

    Class Locale

    The Locale class for handling localized messages

    Index

    Properties

    asyncLoad: (file: string) => Promise<any>

    util/AsyncLoad.js must be loaded via import() to avoid cyclical imports that would cause a ReferenceError for Locale.

    current: string = locale

    The current locale

    data: componentData = {}

    The localized message strings, per component and locale, with the default message for localeError() below.

    default: string = locale

    The default locale for when a message has no current localization

    initialized: boolean = false

    Whether setLocale() has been called or not.

    isComponent: boolean = false

    True when the core component has been loaded (and so the Package path resolution is available)

    locations: { [component: string]: [string, Set<string>] } = ...

    The locale files to load for each locale (as registered by the components)

    Methods

    • Load a localization file and register its contents

      Parameters

      • component: string

        The component whose localization is being loaded

      • locale: string

        The locale being loaded

      • file: string

        The file to load for that localization

      Returns Promise<void>

      A promise that resolves when the file is loaded and registered

    • Report an error thrown when loading a component's locale file, and fall back to loading the default locale if the failed locale was not the default.

      Parameters

      • component: string

        The component whose localization is being loaded

      • locale: string

        The locale being loaded

      • error: Error

        The Error object causing the issue

      Returns void | Promise<void>

      A promise for loading the default locale, or void

    • Find a localized message string, or use the default if not available

      Parameters

      • component: string

        The component for this message

      • id: string

        The id of the message

      Returns string

      The message string to use

    • Get a message string and insert any arguments. The arguments can be positional, or a mapping of names to values. E.g.

      Locale.message('[my]/test', 'Hello', {name: 'World'})); Locale.message('[my]/test', 'FooBar', 'Foo'));

      Parameters

      • component: string

        The component whose message is requested

      • id: string

        The id of the message

      • data: string | namedData = {}

        The first argument or the object of names arguments

      • ...args: string[]

        Any additional string arguments (if data is a string)

      Returns string

      The localized message with arguments substituted in

    • Process a message string by substituting the given arguments. The arguments can be positional, or a data mapping of names to values.

      Parameters

      • message: string

        The message string to process.

      • data: string | namedData = {}

        The first argument or the object of names arguments

      • ...args: string[]

        Additional arguments (if data is a string)

      Returns string

      The processed message string with arguments substituted

    • Registers a given component's locale directory

      Parameters

      • component: string

        The component's name (e.g., [tex]/bbox)

      • prefix: string = component

        The directory where the locales are located

      Returns void

    • Register a set of messages for a given component and locale (called when the localization files are loaded).

      Parameters

      • component: string

        The component's name (e.g., [tex]/bbox)

      • locale: string

        The locale for the messages

      • data: messageData

        The messages indexed by their IDs

      Returns void

    • Set the locale to the given one (or use the current one), and load any needed files (or newly registered files for the current locale).

      Parameters

      • locale: string = ...

        The local to use (or use the current one)

      Returns Promise<void[]>

      A promise that resolves when the locale files have been loaded

    • Substitue arguments into a message string

      Parameters

      • message: string

        The original message string

      • data: namedData

        The mapping of markers to values

      Returns string

      The final string with substitutions made

    • Throw an error with a given string substituting the given parameters

      Parameters

      • component: string

        The component whose message is requested

      • id: string

        The id of the message

      • data: string | namedData = {}

        The first argument or the object of names arguments

      • ...args: string[]

        Any additional string arguments (if data is a string)

      Returns never

    • Report a warning with a given string substituting the given parameters

      Parameters

      • component: string

        The component whose message is requested

      • id: string

        The id of the message

      • data: string | namedData = {}

        The first argument or the object of named arguments

      • ...args: string[]

        Any additional string arguments (if data is a string)

      Returns void