Skip to main content
Version: 5.x.x

Initialization

Standard way to initialize Tolgee is:

import {Tolgee, DevTools, FormatSimple} from '@tolgee/web'

const tolgee = Tolgee()
.use(DevTools())
.use(FormatSimple())
// replace with .use(FormatIcu()) for rendering plurals, foramatted numbers, etc.
.init({
language: 'en'

// for development mode
apiUrl: 'https://app.tolgee.io'
apiKey: '<your tolgee API key>'

// for production
staticData: {
...
}
})

// this part starts loading data
tolgee.run();
danger

Never leak your API key! We strongly recommend against adding API key into git repository.

We use DevTools plugin which will provide in-context translating in dev mode. We also need to provide apiUrl and apiKey for the in-context to work.

Obtaining Tolgee API key is described in Integration chapter.

Check all tolgee options and tolgee plugins.

Tolgee SDK can be used without connection to Tolgee Platform

What does run do?

info

In tolgee integrations run method is usually called automatically in tolgee provider, it is generally better to hook it into framework lifecycle because of SSR.

Tolgee run method will start loading translations data (if necessary) and also activates in-context tools.

You can use tolgee without running it (e.g. on server with ssr). That way tolgee won't activate in-context tools and will not load anything asynchronously, but you can still use tolgee.t function with staticData.