Options
All
  • Public
  • Public/Protected
  • All
Menu

Module i18n

Index

Type aliases

LocalesRegistry

LocalesRegistry: ReturnType<typeof makeLocalesRegistry>

StringsRegistry

StringsRegistry: ReturnType<typeof makeStringsRegistry>

Variables

Const defaultLocale

defaultLocale: "en" = "en"

Functions

Const DomainsRegistry

  • DomainsRegistry(): { Domains: {}; registerDomain: (locale: any, domain: any) => void }
  • Returns { Domains: {}; registerDomain: (locale: any, domain: any) => void }

    • Domains: {}
    • registerDomain: (locale: any, domain: any) => void
        • (locale: any, domain: any): void
        • Parameters

          • locale: any
          • domain: any

          Returns void

Const detectLocale

  • detectLocale(): any
  • Returns any

Const formatLabel

  • formatLabel(options: { collectionName?: string; fieldName: string; intl?: any; modelName?: string; schema: VulcanSchema<AnyObject> }, values?: any): any
  • Parameters

    • options: { collectionName?: string; fieldName: string; intl?: any; modelName?: string; schema: VulcanSchema<AnyObject> }
      • Optional collectionName?: string
        deprecated

        use modelName instead

      • fieldName: string
      • Optional intl?: any
      • Optional modelName?: string
      • schema: VulcanSchema<AnyObject>
    • Optional values: any

    Returns any

Const getIntlKeys

  • getIntlKeys(__namedParameters: { fieldName: string; modelName: string; schema: VulcanSchema<AnyObject> }): string[]
  • Get an array of intl keys to try for a field

    example

    For model Foo of schema { foobar: { type: String, intlId: "foobar_translation"}} => ["foobar_translation", "foo.foobar"]

    Parameters

    • __namedParameters: { fieldName: string; modelName: string; schema: VulcanSchema<AnyObject> }
      • fieldName: string
      • modelName: string
      • schema: VulcanSchema<AnyObject>

    Returns string[]

Const getIntlLabel

  • getIntlLabel(__namedParameters: { collectionName?: string; fieldName: string; intl?: any; isDescription?: boolean; modelName?: string; schema: VulcanSchema<AnyObject> }, values?: any): any
  • getIntlLabel - Get a label for a field, for a given collection, in the current language. The evaluation is as follows : i18n(intlId) > i18n(collectionName.fieldName) > i18n(global.fieldName) > i18n(fieldName)

    Parameters

    • __namedParameters: { collectionName?: string; fieldName: string; intl?: any; isDescription?: boolean; modelName?: string; schema: VulcanSchema<AnyObject> }
      • Optional collectionName?: string
        deprecated

        use modelName instead

      • fieldName: string
      • Optional intl?: any
      • Optional isDescription?: boolean
      • Optional modelName?: string
      • schema: VulcanSchema<AnyObject>
    • Optional values: any

      The values to pass to format the i18n string

    Returns any

    The translated label

Const getIntlString

  • getIntlString(): SimpleSchema & { name: string }
  • Returns SimpleSchema & { name: string }

Const getValidLocale

  • Difference with Meteor: it's now a closure, to avoid having a global "Locales" object, instead pass it from the app

    Parameters

    Returns (localeId: string) => undefined | LocaleType

      • Parameters

        • localeId: string

        Returns undefined | LocaleType

Const initLocale

  • initLocale(Locales: LocaleType[]): (__namedParameters: { cookies?: { locale?: string }; currentUser?: any; locale?: any }) => LocaleType
  • Parameters

    Returns (__namedParameters: { cookies?: { locale?: string }; currentUser?: any; locale?: any }) => LocaleType

      • (__namedParameters: { cookies?: { locale?: string }; currentUser?: any; locale?: any }): LocaleType
      • Parameters

        • __namedParameters: { cookies?: { locale?: string }; currentUser?: any; locale?: any }
          • Optional cookies?: { locale?: string }

            Read the cookie directly

            deprecated

            Pass the "locale" directly

            • Optional locale?: string
          • Optional currentUser?: any
          • Optional locale?: any

            Already known locale

        Returns LocaleType

Const isIntlDataField

  • isIntlDataField(fieldSchema: any): boolean
  • Parameters

    • fieldSchema: any

    Returns boolean

Const isIntlField

  • isIntlField(fieldSchema: any): boolean
  • Parameters

    • fieldSchema: any

    Returns boolean

Const makeLocalesRegistry

  • makeLocalesRegistry(): { Locales: LocaleType[]; getLocale: (localeId: string) => undefined | LocaleType; registerLocale: (locale: any) => void }
  • Create and manage a stateful registry of locales

    Returns { Locales: LocaleType[]; getLocale: (localeId: string) => undefined | LocaleType; registerLocale: (locale: any) => void }

    • Locales: LocaleType[]
    • getLocale: (localeId: string) => undefined | LocaleType
        • Parameters

          • localeId: string

          Returns undefined | LocaleType

    • registerLocale: (locale: any) => void
        • (locale: any): void
        • Parameters

          • locale: any

          Returns void

Const makeStringsRegistry

  • makeStringsRegistry(): { Strings: {}; addStrings: (language: any, strings: any) => void; getString: (__namedParameters: any) => string; getStrings: (localeId: any) => any }
  • Registry of strings for all locales

    Returns { Strings: {}; addStrings: (language: any, strings: any) => void; getString: (__namedParameters: any) => string; getStrings: (localeId: any) => any }

    • Strings: {}
    • addStrings: (language: any, strings: any) => void
        • (language: any, strings: any): void
        • Parameters

          • language: any
          • strings: any

          Returns void

    • getString: (__namedParameters: any) => string
        • (__namedParameters: any): string
        • Parameters

          • __namedParameters: any

          Returns string

    • getStrings: (localeId: any) => any
        • (localeId: any): any
        • Parameters

          • localeId: any

          Returns any

Const schemaHasIntlField

  • schemaHasIntlField(schema: any, fieldName: any): boolean
  • Parameters

    • schema: any
    • fieldName: any

    Returns boolean

Const schemaHasIntlFields

  • schemaHasIntlFields(schema: any): boolean
  • Parameters

    • schema: any

    Returns boolean

Const truncateKey

  • truncateKey(key: any): any
  • Parameters

    • key: any

    Returns any

Const validateIntlField

  • validateIntlField(Locales: LocaleType[]): () => undefined | string

Generated using TypeDoc