Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "src/core"

Index

Variables

Const DEFAULT_VALUE_SEPARATOR

DEFAULT_VALUE_SEPARATOR: ":" = ":"

Const SEPARATOR

SEPARATOR: "." = "."

Functions

Const NOOP

  • NOOP(): any

getSingularFromPlurals

  • Get singular from plurals object.

    Parameters

    Returns string

    Singular.

getValidResult

isStringsArray

  • isStringsArray(maybeStrings: any): maybeStrings is TemplateStringsArray | string[]
  • Check data type.

    Parameters

    • maybeStrings: any

      Maybe array of strings.

    Returns maybeStrings is TemplateStringsArray | string[]

    Given data is array of strings.

localeAccessor

  • localeAccessor(config: Config, locale: string, singular: string, allowDelayedTraversal?: boolean): () => I18nLocale
  • Allows delayed access to translations nested inside objects.

    Parameters

    • config: Config

      Config object.

    • locale: string

      The locale to use.

    • singular: string

      The singular term to look up.

    • Default value allowDelayedTraversal: boolean = true

      Is delayed traversal of the tree allowed? This parameter is used internally. It allows to signal the accessor that a translation was not found in the initial lookup and that an invocation of the accessor may trigger another traversal of the tree.

    Returns () => I18nLocale

    A function that, when invoked, returns the current value stored in the object at the requested location.

localeMutator

  • Allows delayed mutation of a translation nested inside objects.

    description

    Construction of the mutator will attempt to locate the requested term inside the object, but if part of the branch does not exist yet, it will not be created until the mutator is actually invoked. At that point, re-traversal of the tree is performed and missing parts along the branch will be created.

    Parameters

    • config: Config

      Config object.

    • locale: string

      The locale to use.

    • singular: string

      The singular term to look up.

    • Default value allowBranching: boolean = false

      Is the mutator allowed to create previously non-existent branches along the requested locale path?

    Returns (input: I18nLocale) => I18nLocale

    A function that takes one argument. When the function is invoked, the targeted translation term will be set to the given value inside the locale table.

postProcess

  • postProcess(config: Config, text: string, namedValues: any, values: any[], count?: number): string
  • Handling of templates.

    Parameters

    • config: Config
    • text: string

      Text to process.

    • namedValues: any

      Named values for mustache.

    • values: any[]

      List of values for vsprintf.

    • Optional count: number

      Plural param.

    Returns string

    Processed text.

preProcess

  • preProcess<T>(text: T | TemplateStringsArray | string[]): T | string
  • Handling of template literals.

    Type parameters

    • T

    Parameters

    • text: T | TemplateStringsArray | string[]

      Text or text parts.

    Returns T | string

    Processed text.

translate

  • Core translate function.

    Parameters

    • config: Config

      Config object.

    • locale: string

      Target locale.

    • singular: string

      Singular form.

    • Optional plural: string

      Plural form.

    Returns string | I18nPluralLocale

    Translation.

tryParseFloat

  • tryParseFloat(num: string | number): [number, boolean]
  • Parse float from string, if num is string.

    Parameters

    • num: string | number

      Number or string to handle.

    Returns [number, boolean]

    Maybe number and number is or not.

Generated using TypeDoc