Skip to main content
Version: 6.x.x

Core Options

Initial configuration object of tolgee.

language

Initial language, you need to specify this, unless there is LanguageDetector plugin present.

language: string;

defaultLanguage

Used when LanguageDetector plugin fails.

defaultLanguage: string;

fallbackLanguage

A language(s) that is used when no translation is available for the current one.

fallbackLanguage: string | string[] | Object;

You can also specify which language should fallback to which individually:

fallbackLanguage: {
'en-GB': 'en',
'en-IN': ['en-GB', 'en'],
'es-MX': 'es',
}

All the fallback languages will be fetched at the start of the application.

apiUrl

Tolgee instance url (e.g. https://app.tolgee.io)

apiUrl: string;

apiKey

Project API key (PAK) or Personal Access Token (PAT)

apiKey: string;

projectId

Project id is necessary if you are using PAT

projectId: number | string;

availableLanguages

Specify all available languages. Required for language detection or loading all languages at once (loadMatrix). It also limits which values can be stored. Is derrived from staticData keys if not provided.

availableLanguages: string[];

ns

Namespaces which should be always fetched

ns: string[];

fallbackNs

Namespaces to search when translation is not found.

fallbackNs: FallbackNs;

defaultNs

Default namespace when no namespace defined (default: empty string)

defaultNs: string;

availableNs

Specify all available namespaces. Required for loading all namespaces at once (loadMatrix).

availableNs: string[];

staticData

These data go directly to cache or you can specify async function which will be used to get the data. Use : to add namespace:

staticData: TolgeeStaticData;

Example:

{
'locale': {
'key': 'translation'
},
// or
'locale': () => fetchTranslations(),
// or
'locale:namespace': ...
}

onFormatError

Defines what gets displayed when formatter throws an error. (Default: "invalid")

onFormatError: string
onFormatError(error: string, info: TranslationInfo): string

onTranslationMissing

Is called every time translation is missing. If no orEmpty or defaultValue are defined, return value is rendered. (function is called regardless)

onTranslationMissing(info: TranslationInfo): string

tagNewKeys

Specify tags that will be preselected for non-existent keys

tagNewKeys: string[]

observerType

Switches between invisible and text observer if present. (Default: "invisible")

observerType: 'invisible' | 'text';

observerOptions

Observer options object.