Gettext class providing localization methods.

Hierarchy

  • Gettext

Constructors

  • Parameters

    • Optional options: IOptions

    Returns Gettext

Properties

_contextDelimiter: any
_defaults: any
_dictionary: any
_domain: any
_locale: any
_pluralForms: any
_pluralFuncs: any
_stringsPrefix: any
expandLocale: any

Split a locale into parent locales. "es-CO" -> ["es-CO", "es"]

Param

The locale string.

Returns

An array of locales.

getPluralFunc: any

Split a locale into parent locales. "es-CO" -> ["es-CO", "es"]

Param

Plural form string..

Returns

An function to compute plural forms.

removeContext: any

Remove the context delimiter from string.

Param

Translation string.

Returns

A translation string without context.

setMessages: any

Set messages after loading them.

Param

The translation domain.

Param

The translation locale.

Param

List of translation strings.

Param

Plural form string.

Notes

Contains juicy parts of https://github.com/Orange-OpenSource/gettext.js/blob/master/lib.gettext.js

t: any

Proper translation function that handle plurals and directives.

Param

List of translation strings.

Param

The number for pluralization.

Param

Translation options.

Param

Any variables to interpolate.

Returns

A translation string without context.

Notes

Contains juicy parts of https://github.com/Orange-OpenSource/gettext.js/blob/master/lib.gettext.js

Methods

  • Shorthand for gettext.

    Parameters

    • msgid: string

      The singular string to translate.

    • Rest ...args: any[]

      Any additional values to use with interpolation.

    Returns string

    A translated string if found, or the original string.

    Notes

    This is not a private method (starts with an underscore) it is just a shorter and standard way to call these methods.

  • Shorthand for ngettext.

    Parameters

    • msgid: string

      The singular string to translate.

    • msgid_plural: string

      The plural string to translate.

    • n: number

      The number for pluralization.

    • Rest ...args: any[]

      Any additional values to use with interpolation.

    Returns string

    A translated string if found, or the original string.

    Notes

    This is not a private method (starts with an underscore) it is just a shorter and standard way to call these methods.

  • Shorthand for npgettext.

    Parameters

    • msgctxt: string

      The message context.

    • msgid: string

      The singular string to translate.

    • msgid_plural: string

      The plural string to translate.

    • n: number

      The number for pluralization.

    • Rest ...args: any[]

      Any additional values to use with interpolation.

    Returns string

    A translated string if found, or the original string.

    Notes

    This is not a private method (starts with an underscore) it is just a shorter and standard way to call these methods.

  • Shorthand for pgettext.

    Parameters

    • msgctxt: string

      The message context.

    • msgid: string

      The singular string to translate.

    • Rest ...args: any[]

      Any additional values to use with interpolation.

    Returns string

    A translated string if found, or the original string.

    Notes

    This is not a private method (starts with an underscore) it is just a shorter and standard way to call these methods.

  • Translate a singular string with extra interpolation values.

    Parameters

    • domain: string

      The translations domain.

    • msgctxt: string

      The message context.

    • msgid: string

      The singular string to translate.

    • msgid_plural: string

      The plural string to translate.

    • n: number

      The number for pluralization.

    • Rest ...args: any[]

      Any additional values to use with interpolation

    Returns string

    A translated string if found, or the original string.

  • Get current context delimiter.

    Returns string

    The current delimiter.

  • Get current domain.

    Returns string

    The current domain string.

  • Get current locale.

    Returns string

    The current locale.

  • Get current strings prefix.

    Returns string

    The strings prefix.

  • Translate a singular string with extra interpolation values.

    Parameters

    • msgid: string

      The singular string to translate.

    • Rest ...args: any[]

      Any additional values to use with interpolation.

    Returns string

    A translated string if found, or the original string.

  • Load json translations strings (In Jed 2.x format).

    Parameters

    • jsonData: IJsonData

      The translation strings plus metadata.

    • domain: string

      The translation domain, e.g. "jupyterlab".

    Returns void

  • Translate a plural string with extra interpolation values.

    Parameters

    • msgid: string

      The singular string to translate.

    • msgid_plural: string
    • n: number
    • Rest ...args: any[]

      Any additional values to use with interpolation.

    Returns string

    A translated string if found, or the original string.

  • Translate a contextualized plural string with extra interpolation values.

    Parameters

    • msgctxt: string

      The message context.

    • msgid: string

      The singular string to translate.

    • msgid_plural: string

      The plural string to translate.

    • n: number

      The number for pluralization.

    • Rest ...args: any[]

      Any additional values to use with interpolation

    Returns string

    A translated string if found, or the original string.

  • Translate a contextualized singular string with extra interpolation values.

    Parameters

    • msgctxt: string

      The message context.

    • msgid: string

      The singular string to translate.

    • Rest ...args: any[]

      Any additional values to use with interpolation.

    Returns string

    A translated string if found, or the original string.

    Notes

    This is not a private method (starts with an underscore) it is just a shorter and standard way to call these methods.

  • Set current context delimiter.

    Parameters

    • delimiter: string

      The delimiter to set.

    Returns void

  • Set current domain.

    Parameters

    • domain: string

      The domain to set.

    Returns void

  • Set current locale.

    Parameters

    • locale: string

      The locale to set.

    Returns void

  • Set current strings prefix.

    Parameters

    • prefix: string

      The string prefix to set.

    Returns void

  • sprintf equivalent, takes a string and some arguments to make a computed string.

    Parameters

    • fmt: string

      The string to interpolate.

    • Rest ...args: any[]

      The variables to use in interpolation.

      Examples

      strfmt("%1 dogs are in %2", 7, "the kitchen"); => "7 dogs are in the kitchen" strfmt("I like %1, bananas and %1", "apples"); => "I like apples, bananas and apples"

    Returns string

Generated using TypeDoc