localization-gradle-plugin

Cross-platform localization generated in Gradle

View the Project on GitHub hendraanggrian/localization-gradle-plugin

Plugin Portal OpenJDK

Localization Gradle Plugin

An write-once-run-anywhere approach to localization in multiple platform project.

Download

Using plugins DSL:

plugins {
    id('com.hendraanggrian.localization') version "$version"
}

Using legacy plugin application:

buildscript {
    repositories {
        gradlePluginPortal()
    }
    dependencies {
        classpath("com.hendraanggrian:localization-gradle-plugin:$version")
    }
}

apply plugin: 'com.hendraanggrian.localization'

Usage

Apply plugin in your module, and configure localization extension like below:

localization {
    resourceName.set('strings')
    text('home') {
        en = 'Home'
        id = 'Beranda'
    }
    text('about') {
        en = 'About'
        id = 'Tentang'
    }
}

tasks {
    localizeJvm {
        outputDirectory.set(new File('src/main/resources'))
    }
    localizeAndroid {
        outputDirectory.set(new File('my/custom/directory'))
    }
}

It's even simpler with Gradle Kotlin DSL.

localization {
    "home" {
        en = "Home"
        id = "Beranda"
    }
    "about" {
        en = "About"
        id = "Tentang"
    }
}

Then use command localizeJvm or localizeAndroid to write localization files into their respective directory.