Core Events
Tolgee events which can be listened through tolgee.on
method.
language
Emitted on language change.
tolgee.on('language', handler: Handler<LanguageEvent>)
pendingLanguage
Emitted on language change. Before languages are loaded (when tolgee is running).
tolgee.on('pendingLanguage', handler: Handler<PendingLanguageEvent>)
loading
Emitted on loading change. Changes when tolgee is loading some data for the first time.
tolgee.on('loading', handler: Handler<LoadingEvent>)
fetching
Emitted on fetching change. Changes when tolgee is fetching any data.
tolgee.on('fetching', handler: Handler<FetchingEvent>)
initialLoad
Emitted when run
method finishes.
tolgee.on('initialLoad', handler: Handler<InitialLoadEvent>)
running
Emitted when internal running
state changes.
tolgee.on('running', handler: Handler<RunningEvent>)
cache
Emitted when cache changes.
tolgee.on('cache', handler: Handler<CacheEvent>)
update
Emitted when any key needs (or might need) to be re-rendered. It's derrived from other events
(initialLoad
, language
, cache
), the events are grouped when multiple happen at the same time,
so it only results to one update
event being emitted.
tolgee.on('update', handler: CombinedHandler<UpdateEvent>)
You can check what events triggered this change event from the first argument of the handler.
tolgee.on('update', (events) => events.forEach(e => ...))
error
Emitted when there is an error. You can intercept different types of errors, connected to fetching language data, detecting language or loading/storing language, you can filter them by name
property on the error, which can be:
RecordFetchError
- error when fetching translations record, you can also readlanguage
andnamespace
properties, to see which record has failedLanguageDetectorError
- error when detecting language through language detector pluginLanguageStorageError
- error when loading/saving language through language storage plugin
tolgee.on('error', handler: Handler<ErrorEvent>)