Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Config

Hierarchy

  • Config

Implements

Index

Constructors

constructor

Properties

cookieName

cookieName: string = null

defaultLocale

defaultLocale: string = "en"

fallbacks

fallbacks: I18nFallbacks

Private forks

forks: Config[] = []

Private Readonly isConstructed

isConstructed: boolean = false

isDestroyed

isDestroyed: boolean = false

Private isFork

isFork: boolean = false

locales

locales: I18nLocales

objectNotation

objectNotation: boolean = false

processors

processors: I18nProcessor[] = []

queryParameter

queryParameter: string = "locale"

unknownPhraseListener

unknownPhraseListener: I18nUnknownPhraseListener = null

Methods

addLocale

  • Add new translations.

    Parameters

    • locale: string

      Locale to add.

    • catalog: I18nLangLocales

      Catalog for localte to add.

    Returns this

    Config.

bind

  • bind<T>(fn: T): T
  • bind<A, B, C, D>(fns: []): []
  • Create translate function copy, binded to another config.

    Type parameters

    • T: Function

    Parameters

    • fn: T

      Translate function.

    Returns T

    Binded function.

  • Create translate functions copy, binded to another config.

    Type parameters

    • A: Function

    • B: Function

    • C: Function

    • D: Function

    Parameters

    • fns: []

      Translate functions.

    Returns []

    Binded functions.

Private callForkMethod

  • Call given method for all forks.

    Parameters

    • caller: (fork: Config) => void

      Function to call method of fork.

    • flagName: keyof I18nForkLinkedFields

      Flag name to check ability to call method.

    Returns void

configure

  • configure(__namedParameters: { cookieName: string; defaultLocale: string; fallbacks: {}; locales: I18nLocales; objectNotation: boolean; processors: ((text: string, namedValues: any, values: any[], count?: number) => string)[]; queryParameter: string; unknownPhraseListener: (locale: string, phrase: string, value: I18nLocale) => void }): this
  • Change config.

    Parameters

    • __namedParameters: { cookieName: string; defaultLocale: string; fallbacks: {}; locales: I18nLocales; objectNotation: boolean; processors: ((text: string, namedValues: any, values: any[], count?: number) => string)[]; queryParameter: string; unknownPhraseListener: (locale: string, phrase: string, value: I18nLocale) => void }
      • cookieName: string
      • defaultLocale: string
      • fallbacks: {}
      • locales: I18nLocales
      • objectNotation: boolean
      • processors: ((text: string, namedValues: any, values: any[], count?: number) => string)[]
      • queryParameter: string
      • unknownPhraseListener: (locale: string, phrase: string, value: I18nLocale) => void
          • (locale: string, phrase: string, value: I18nLocale): void
          • Parameters

            Returns void

    Returns this

    Config.

destroy

  • destroy(): void

fork

  • Copy current config with some overrides.

    Parameters

    • Optional config: I18nForkConfig

      Config with overrides.

    • Optional hard: boolean

      Do hard fork without linked fields.

    Returns Config

    Forked config.

  • Copy current config with some overrides.

    Parameters

    • config: I18nConfig

      Config with overrides.

    • hard: true

      Do hard fork without linked fields.

    Returns Config

    Forked config.

getCatalog

  • Get whole catalog optionally based on given locale.

    Parameters

    • Optional locale: string

      Locale to get sub-catalog.

    Returns I18nLangLocales

    Catalog.

getLocale

  • getLocale(checkFallback?: true, localeToCheck?: string, strict?: boolean): string
  • Get current locale.

    Parameters

    • Optional checkFallback: true

      Flag to use fallback or not.

    • Optional localeToCheck: string

      Locale to handle.

    • Default value strict: boolean = false

      Should fall back to default locale or not.

    Returns string

    Current locale.

getLocales

  • getLocales(): string[]
  • Get available locales.

    Returns string[]

    Available locales.

onUnknownPhrase

removeLocale

  • removeLocale(locale: string): this
  • Remove translations.

    Parameters

    • locale: string

      Locale to remove.

    Returns this

    Config.

setLocale

  • setLocale(locale: string): this
  • Set current locale.

    Parameters

    • locale: string

      Locale to set.

    Returns this

    Config.

Object literals

Private forkLinkedFields

forkLinkedFields: object

defaultLocale

defaultLocale: true = true

locales

locales: true = true

unknownPhraseListener

unknownPhraseListener: true = true

Generated using TypeDoc