A framework-agnostic i18n registry with vue-i18n-like API names.

Key methods:

  • getLocaleMessages(): returns all messages (for vue-i18n { messages })
  • getLocaleMessage(locale): returns single locale messages
  • setLocaleMessage(locale, messages): replace locale messages
  • mergeLocaleMessage(locale, messages): deep-merge into existing locale (fixed)
  • t(locale, key, options): translation helper for core code (no Vue required)

Constructors

Properties

events: { localeChanged: AcCmEventManager<AcApLocaleChangedEventArgs> } = ...

Supported events

Type declaration

  • localeChanged: AcCmEventManager<AcApLocaleChangedEventArgs>

    Fired when locale changed

Accessors

  • get currentLocale(): AcApLocale

    Get the currently active locale.

    Returns AcApLocale

    The locale currently used for translation.

    console.log(AcApI18n.currentLocale)  // "en" or "zh"
    
  • get messages(): Readonly<AcApLocaleMessages>

    Return the whole messages map (for vue-i18n initialisation).

    Returns Readonly<AcApLocaleMessages>

Methods

  • Get localized command description

    Parameters

    • groupName: string

      Command group name

    • cmdName: string

      Global command name

    Returns string

    • The localized command description.
  • Return the messages object for a single locale.

    Parameters

    Returns Readonly<AcApLocaleMessage>

  • Deep-merge a message dictionary into an existing locale.

    Type Parameters

    Parameters

    • locale: L
    • messages: AcApLocaleMessage

    Returns void

  • Register a plugin's messages. Alias for mergeLocaleMessage for consistency with vue-i18n.

    Type Parameters

    Parameters

    • locale: L
    • messages: AcApLocaleMessage

    Returns void

  • Set the current active locale for translation.

    Parameters

    • locale: AcApLocale

      Locale to activate ("en" or "zh")

    Returns void

    This method updates the internal locale state used by all future calls to t(key, options). After calling this method, the entire application will use the new locale automatically.

    AcApI18n.setCurrentLocale('zh')
    console.log(AcApI18n.t('core.start')) // uses Chinese messages
  • Tries to find command in system group and gets its localized command description

    Parameters

    • name: string

    Returns string

    • The localized command description
  • Translate a dotted key path using the registry (no Vue required).

    Parameters

    • key: string

      dotted path, e.g. "core.start" or "pluginX.button.ok"

    • Optionaloptions: AcApTranslateOptions

      optional fallback

    Returns string

    translated string or fallback/key if not found

  • Tries to find command in user group and gets its localized command description

    Parameters

    • name: string

    Returns string

    • The localized command description