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
Languages which can be used for language detection
and 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;
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.