To use Tolgee with Gatsby follow this Guide.
- Created Gatsby project with installed
- Created project in Tolgee platform with 2 languages. In our case it is English (en) and Czech (cs).
- Added some localization key and translations for both languages. In our case the key name is
- Generated API key for your project
- Exported data as zip of jsons
Create file (if not exists)
.env.development and add this content to it.
<your api key> with your generated API key.
Save exported json files to
src/i18n folder in your project structure.
English version in the root.
Czech version in
The localization data is imported and provided to TolgeeProvider using
staticData prop, so in production mode
(when your page is built) Tolgee will use this data.
forceLanguage prop forces Tolgee to use specific language. It won't try to change it
using its own way.
HomePageInner component can contain some translations
You are done! Now you can translate your strings directly in your application, and enjoy the features of Gatsby in the same time! You can find final application code in this repo: github.com/tolgee/gatsby-example.
Now you can use translation methods described here.