Skip to content

tolgee/tolgee-mobile-kotlin-sdk

Repository files navigation

Tolgee Mobile Kotlin SDK (Alpha) 🐁

Tolgee Android Jetpack Compose Compose Multiplatform language github release licence github stars github stars Github discussions Dev.to Read the Docs Slack YouTube LinkedIn X

What is Tolgee?

Tolgee is a powerful localization platform that simplifies the translation process for your applications. This SDK provides integration for Kotlin-based projects, with a primary focus on Android.

Currently, Android is fully supported, but any Kotlin-based codebase can in theory use this library.

Features

  • Over-the-air updates: Update your translations without releasing a new app version
  • Multiple format support:
    • Sprintf (Android SDK) formatting
    • ICU (Tolgee Native Flat JSON) formatting
  • Compose integration: Full integration with Jetpack Compose and Compose Multiplatform
  • Compiler plugin: Automatically transform existing code to use Tolgee without manual changes
  • Kotlin Multiplatform: Designed with multiplatform support in mind

Modules

The SDK is split into multiple modules, each serving a specific purpose:

  • Core: Base library for fetching translations from CDN and querying them
  • Compose: Extension for using the library with Jetpack Compose or Compose Multiplatform
  • Gradle Plugin: Gradle plugin for integrating and configuring the compiler plugin

Which Module Should I Use?

  • If you are using traditional Android Views, use the Core module
  • If you are using Jetpack Compose or Compose Multiplatform, use the Compose module
  • If you want to automatically transform existing code to use Tolgee, add the Gradle Plugin

Installation

Note

For managing static translations (used as fallback), check out tolgee-cli. It provides tools for updating and syncing your static translation files.

In each demo project you can find an example of .tolgeerc configuration file.

Using Version Catalog is highly recommended to keep your versions aligned.

Core Module (Traditional Android)

# gradle/libs.versions.toml
[libraries]
tolgee = { group = "io.tolgee.mobile-kotlin-sdk", name = "core", version.ref = "tolgee" }
// build.gradle.kts
dependencies {
    implementation(libs.tolgee)
}

Compose Module (Jetpack Compose or Compose Multiplatform)

# gradle/libs.versions.toml
[libraries]
tolgee = { group = "io.tolgee.mobile-kotlin-sdk", name = "compose", version.ref = "tolgee" }
// build.gradle.kts
dependencies {
    implementation(libs.tolgee)
}

Gradle Plugin (Compiler Plugin)

# gradle/libs.versions.toml
[plugins]
tolgee = { id = "io.tolgee.mobile-kotlin-sdk", version.ref = "tolgee" }
// build.gradle.kts
plugins {
    alias(libs.plugins.tolgee)
}

Basic Usage

For detailed usage instructions, please refer to the module-specific documentation:

Quick Start

Here's a quick example of initializing Tolgee in an Android application:

class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()

        Tolgee.init {
            contentDelivery {
                url = "https://cdn.tolg.ee/your-cdn-url-prefix"
                storage = TolgeeStorageProviderAndroid(this@MyApplication, BuildConfig.VERSION_CODE)
            }
        }
    }
}

Example Projects

For complete examples of how to use the Tolgee SDK, check out the demo projects:

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. Check out guidelines.md for some information about the project internals and information about the workflow.

License

This project is licensed under the Apache License 2.0—see the LICENSE file for details.

Contributors

contributors

Let us know what you think! #FeedbackWanted ❤️


🧀