Gettext class providing localization methods.

Constructors

Properties

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

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.

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

    Parameters

    • locale: string

      The locale string.

    Returns string[]

    An array of locales.

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

    Parameters

    • pluralForm: string

      Plural form string..

    Returns Function

    An function to compute plural forms.

  • 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.

  • Remove the context delimiter from string.

    Parameters

    • str: string

      Translation string.

    Returns string

    A translation string without context.

  • Set current context delimiter.

    Parameters

    • delimiter: string

      The delimiter 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