Setup
After installing the Tolgee SDK, you need to initialize it in your application. This one-time setup process:
- Configures the SDK to connect to your translation content delivery network (CDN)
- Sets up local caching for offline access and performance
- Establishes the global Tolgee instance that your entire app can access
- Enables over-the-air translation updates without releasing a new app version
Once properly initialized, Tolgee will automatically handle translation fetching, caching, and updates throughout your application's lifecycle.
Initialization Configuration
This initialization applies to all Tolgee Android SDK variants - Android Views (Core), Jetpack Compose, and Kotlin Multiplatform.
Android
Initialize Tolgee in your Application class:
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
Tolgee.init {
contentDelivery {
url = "https://cdn.tolg.ee/your-cdn-url-prefix" // from Tolgee Platform → Content Delivery
storage = TolgeeStorageProviderAndroid(this@MyApplication, BuildConfig.VERSION_CODE) // cache invalidates on app update
}
}
}
}
Make sure that your app knows where to download translations
For your app to download translation files, you need to provide a CDN URL prefix specific to your project. This prefix points to the catalog that contains your app's translations.
To get your CDN URL prefix:
- Open Tolgee Platform → your Project → Developer settings → Content Delivery
- Copy the full CDN URL prefix
- You can use different prefixes per environment (dev/staging/prod)
If you have a different integration setup (for example, using tolgee-cli and bundling JSON translation files in assets), the initialization may look different.
Kotlin Multiplatform (Non-Android Targets)
For non-Android targets in Kotlin Multiplatform projects, initialization is similar but requires a custom storage provider:
fun initTolgee() {
Tolgee.init {
contentDelivery {
url = "https://cdn.tolg.ee/your-cdn-url-prefix"
// Create a custom storage provider for caching the latest translations from CDN if needed
}
}
}
You'll need to implement your own storage provider for non-Android platforms to enable caching of translations.
Alternative Setup: Using Static Data
If you prefer to bundle translations with your app or need offline-first capabilities, you can use Tolgee CLI to manage translations as static files.
Using Tolgee CLI with static files is ideal for:
- Offline-first applications
- Apps with strict security requirements
- Development environments without internet access
- CI/CD pipelines that need deterministic builds