Skip to content

Repository files navigation

messagevisor-example-android

A small native Android application written in Kotlin, showing how to use the published Messagevisor Java SDK.

The application downloads a production Messagevisor datafile, creates an SDK instance with the ICU module, and renders plain and formatted translations.

Learn more at messagevisor.com.

Requirements

Install Android Studio with Android SDK 36 and JDK 17.

The project uses the Kotlin support built into Android Gradle Plugin 9, so it does not require the older Kotlin Android Gradle plugin.

Messagevisor Java is published through GitHub Packages. Add your GitHub username and a personal access token with the read:packages scope to ~/.gradle/gradle.properties:

gpr.user=YOUR_GITHUB_USERNAME
gpr.key=YOUR_GITHUB_TOKEN

Keep these credentials outside the repository. For GitHub Actions, grant the example repository read access to the Messagevisor Java packages.

Run the application

  1. Open the repository in Android Studio.
  2. Allow Gradle to sync and resolve Messagevisor Java 0.2.0.
  3. Select an Android emulator or connected device.
  4. Run the app configuration.

Messagevisor usage

The application fetches this production datafile:

https://messagevisor-example-cloudflare-pages.pages.dev/production/messagevisor-mobile-en-US.json

The important SDK usage is in MainActivity.kt:

val m = Messagevisor.create(
    MessagevisorOptions.builder()
        .datafile(datafileJson)
        .timeZone("America/New_York")
        .addModule(IcuModule.create())
        .build(),
)

val signIn = m.translate("auth.signin")
val contact = m.translate(
    "nav.contact",
    mapOf("closingTime" to closingTime),
)

Checks

Run unit tests, Android lint, and a debug build with:

make build

Learn more in the Messagevisor Java SDK documentation.

License

MIT

About

Android app example using Messagevisor Java SDK

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages