localise-gradle-plugin

Additional

Language
Groovy
Version
v.0.1 (Mar 30, 2018)
Created
Mar 9, 2018
Updated
Apr 14, 2018
Owner
Andriy Matkivskiy (amatkivskiy)
Contributor
Andriy Matkivskiy (amatkivskiy)
1
Activity
Badge
Generate
Download
Source code
APK file

Blurb

Localise.biz gradle plugin for Android projects

This is a gradle plugin for Android projects that fetches localisation strings.xml from localise.biz web service and places it under res/ folder. 💥 Multiple translations are also supported.

Download

buildscript {
    repositories {
      jcenter()
    }

    dependencies {
      classpath 'com.github.amatkivskiy:localise:0.1'
    }
}

Usage

In app/build.gradle

apply plugin: 'com.android.application'
// make sure this line comes *after* you apply the Android plugin
apply plugin: 'localise'

android {
  // your Android project configuration
}

localise {
    localiseKey "LOCALISE_PROJECT_KEY" // Localise.biz project API key.
    fallbackLanguage "en-EN" // empty by default.
    filters = ["en", "ua"] // specifies list of langauges to download. Empty by default.
}

Advanced usage

If you need you can link downloadLocaliseTranslations to any task in Android project so they can be executed sequentally:

task updateStringsAndBuild {
    dependsOn "downloadLocaliseTranslations"
    finalizedBy "build"
}

How it works

This plugin adds gradle downloadLocaliseTranslations task to Android project which downloads localised strings.xml into main's flavor res/ folder.

‼️ Please be careful, as this task will replace all existing strings.xml files in that folder. ☝️ If you store some untranslated resources in strings.xml it is recommended to move them into separate file like: non-translated.xml.