Options
All
  • Public
  • Public/Protected
  • All
Menu

This class manages the internationalization of the module, altering the results synthesized by time writers.

Translations are stored in files located at src/locales. These files contain the transcription for time units and linguistic configurations.


See Contributing: Translating if you wish to contribute with a new translation for timecount.

Hierarchy

  • Locale

Index

Accessors

Static currentIdentifier

  • get currentIdentifier(): string
  • Gets the current locale identifier.

    deprecated

    Since v1.1.0 - In favor of get (will be removed in v2).

    Returns string

Static settings

Methods

Static get

  • get(): string
  • Gets the current locale identifier (e.g.: "fr" represents French — the international translation for the language as a whole; "fr-ca" is French (Canada) — represents a localized variation of the French language meant for Canada).

    The default is "en-us", which represents English (United States), a language built into the module (doesn't require any translation file).

    Returns string

Static isAvailable

  • isAvailable(localeIdentifier: string): boolean
  • Gets whether the given locale identifier is available to timecount.

    Parameters

    • localeIdentifier: string

      A language / region locale specifier (e.g. "en-au", "pt-br").

    Returns boolean

    True if a valid locale was provided; false otherwise.

Static listAvailable

  • listAvailable(): string[]
  • Gets a list with all locale identifiers available to timecount.

    Returns string[]

    An array with all available locale identifiers.

Static set

  • set(localeIdentifier?: string): void
  • Sets the current timecount language using the specified locale identifier (e.g.: "pt" represents Portuguese — the international translation for the language as a whole; "pt-br" is Portuguese (Brazilian) — represents a localized variation of the Portuguese language meant for Brazil).

    throws

    Error When the locale identifier is invalid.

    Parameters

    • Default value localeIdentifier: string = "en"

      A string with a 2 letter language identifier ("en", "es", "pt", etc.) -or- a 5 letter language + region identifier ("en-ca", "pt-ao"). This parameter is case-insensitive. If empty, it will reset the locale to "en".

    Returns void

Generated using TypeDoc