Tolgee can be used in any web application. It is completely framework independent. There are prepared packages for React and Angular. But first of all, let's look on simple application without any framework.
Check out our example application on github
Let's start with simple html code:
There is text
Hello world! in the body, which we would like to translate.
Loading Tolgee in your web application is as simple as including one dependency. To do so, we can simply use unpkg repository:
To translate your content interactively, you will need one more dependency.
This dependency is Tolgee's UI, so dialog can appear when you ALT + click your translation.
Now it's time to configure the library. To do so, just pass configuration object as first parameter of Tolgee constructor.
In configuration object you can specify many other parameters, but in this example we stick with:
- apiUrl - url of the api, where we are saving the data
- apiKey - which you can obtain in the app or in your self-hosted app by following this documentation page
- inputPrefix - character sequence which appears before the text you wish to translate
- inputSuffix - character sequence which appears after the text you wish to translate
- watch - parameter defining whether Tolgee should watch for changes in the DOM and update translations
- ui - constructor of Tolgee's UI to render interactive translation modal window
Afterwards you create the instance you need to wrap the text Hello world! with your
Finally, lets run the beast!
You should end with this HTML document:
After opening this document in a browser you should be able to
ALT + click your text and translate it directly.
After that you should see your translated version right away!