Interface InitOptions<T>

Type Parameters

  • T = object

Hierarchy

Properties

appendNamespaceToCIMode?: boolean

Prefixes the namespace to the returned key when using cimode

Default

false
appendNamespaceToMissingKey?: boolean

Appends namespace to missing key

Default

false
backend?: T

Options for backend - check documentation of plugin

Default

undefined
cache?: object

Options for cache layer - check documentation of plugin

Default

undefined
cleanCode?: boolean

Language will be lowercased EN --> en while leaving full locales like en-US

Default

false
compatibilityJSON?: "v1" | "v4" | "v2" | "v3"

Compatibility JSON version

Default

'v4'
contextSeparator?: string

Char to split context from key

Default

'_'
debug?: boolean

Logs info level to console output. Helps finding issues with loading not working.

Default

false
defaultNS?: string | false | readonly string[]

Default namespace used if not passed to translation function

Default

'translation'
detection?: object

Options for language detection - check documentation of plugin

Default

undefined
fallbackLng?: false | FallbackLng

Language to use if translations in user language are not available.

Default

'dev'
fallbackNS?: string | false | readonly string[]

String or array of namespaces to lookup key if not found in given namespace.

Default

false
i18nFormat?: object

Options for i18n message format - check documentation of plugin

Default

undefined
ignoreJSONStructure?: boolean

Automatically lookup for a flat key if a nested key is not found an vice-versa

Default

true
initImmediate?: boolean

Triggers resource loading in init function inside a setTimeout (default async behaviour). Set it to false if your backend loads resources sync - that way calling i18next.t after init is possible without relaying on the init callback.

Default

true
interpolation?: InterpolationOptions
joinArrays?: string | false

Char, eg. '\n' that arrays will be joined by

Default

false
keySeparator?: string | false

Char to separate keys

Default

'.'
lng?: string

Language to use (overrides language detection)

Default

undefined
load?: "all" | "currentOnly" | "languageOnly"

Language codes to lookup, given set language is 'en-US': 'all' --> ['en-US', 'en', 'dev'], 'currentOnly' --> 'en-US', 'languageOnly' --> 'en'

Default

'all'
locizeLastUsed?: {
    allowedHosts?: readonly string[];
    apiKey?: string;
    debounceSubmit?: number;
    projectId: string;
    referenceLng?: string;
    version?: string;
}

Type declaration

  • Optional allowedHosts?: readonly string[]

    Hostnames that are allowed to send last used data. Please keep those to your local system, staging, test servers (not production)

    Default

    ['localhost']
    
  • Optional apiKey?: string

    An api key if you want to send missing keys

  • Optional debounceSubmit?: number

    Debounce interval to send data in milliseconds

    Default

    90000
    
  • projectId: string

    The id of your locize project

  • Optional referenceLng?: string

    The reference language of your project

    Default

    'en'
    
  • Optional version?: string

    Version

    Default

    'latest'
    

Default

undefined
lowerCaseLng?: boolean

Language will be lowercased eg. en-US --> en-us

Default

false
maxParallelReads?: number

Limit parallelism of calls to backend This is needed to prevent trying to open thousands of sockets or file descriptors, which can cause failures and actually make the entire process take longer.

Default

10
maxRetries?: number

The maximum number of retries to perform. Note that retries are only performed when a request has no response and throws an error. The default value is used if value is set below 0.

Default

5
missingInterpolationHandler?: ((text, value, options) => any)

Type declaration

    • (text, value, options): any
    • Gets called in case a interpolation value is undefined. This method will not be called if the value is empty string or null

      Parameters

      Returns any

      Default

      noop
      
missingKeyHandler?: false | ((lngs, ns, key, fallbackValue, updateMissing, options) => void)

Used for custom missing key handling (needs saveMissing set to true!)

Type declaration

    • (lngs, ns, key, fallbackValue, updateMissing, options): void
    • Parameters

      • lngs: readonly string[]
      • ns: string
      • key: string
      • fallbackValue: string
      • updateMissing: boolean
      • options: any

      Returns void

Default

false
missingKeyNoValueFallbackToKey?: boolean

Used to not fallback to the key as default value, when using saveMissing functionality. i.e. when using with i18next-http-backend this will result in having a key with an empty string value.

Default

false
nonExplicitSupportedLngs?: boolean

If true will pass eg. en-US if finding en in supportedLngs

Default

false
ns?: string | readonly string[]

String or array of namespaces to load

Default

'translation'
nsSeparator?: string | false

Char to split namespace from key

Default

':'
partialBundledLanguages?: boolean

Allow initializing with bundled resources while using a backend to load non bundled ones.

Default

false
pluralSeparator?: string

Char to split plural from key

Default

'_'
postProcess?: string | false | readonly string[]

String or array of postProcessors to apply per default

Default

false
postProcessPassResolved?: boolean

passthrough the resolved object including 'usedNS', 'usedLang' etc into options object of postprocessors as 'i18nResolved' property

Default

false
preload?: false | readonly string[]

Array of languages to preload. Important on server-side to assert translations are loaded before rendering views.

Default

false
react?: ReactOptions

Options for react - check documentation of plugin

Default

undefined
resources?: Resource

Resources to initialize with (if not using loading or not appending using addResourceBundle)

Default

undefined
retryTimeout?: number

Set how long to wait, in milliseconds, between retries of failed requests. This number is compounded by a factor of 2 for subsequent retry. The default value is used if value is set below 1ms.

Default

350
returnDetails?: boolean

Returns an object that includes information about the used language, namespace, key and value

Default

false
returnEmptyString?: boolean

Allows empty string as valid translation

Default

true
returnNull?: boolean

Allows null values as valid translation

Default

false
returnObjects?: boolean

Allows objects as valid translation result

Default

false
saveMissing?: boolean

Calls save missing key function on backend if key not found.

Default

false
saveMissingPlurals?: boolean

Calls save missing key function on backend if key not found also for plural forms.

Default

false
saveMissingTo?: "all" | "current" | "fallback"

Default

'fallback'
simplifyPluralSuffix?: boolean

Will use 'plural' as suffix for languages only having 1 plural form, setting it to false will suffix all with numbers

Default

true
supportedLngs?: false | readonly string[]

Array of allowed languages

Default

false
updateMissing?: boolean

Experimental: enable to update default values using the saveMissing (Works only if defaultValue different from translated value. Only useful on initial development or when keeping code as source of truth not changing values outside of code. Only supported if backend supports it already)

Default

false

Methods

  • Sets defaultValue

    Parameters

    • args: string[]

    Returns TOptions<$Dictionary>

    Default

    args => ({ defaultValue: args[1] })
    
  • Receives a key that was not found in t() and returns a value, that will be returned by t()

    Parameters

    • key: string
    • Optional defaultValue: string
      Optional

    Returns any

    Default

    noop
    
  • Gets called if object was passed in as key but returnObjects was set to false

    Parameters

    • key: string
    • value: string
    • options: any

    Returns void

    Default

    noop
    

Generated using TypeDoc