Skip to content

Translations gradle plugin automates work with lokalise translations in Android application sources.

License

Notifications You must be signed in to change notification settings

intermedia-net/translations

Repository files navigation

Translations gradle plugin

Translations gradle plugin automates work with lokalise translations in Android application code base.

Build Status License: MIT Code Coverage

Gradle plugin version

Getting started

Define plugin

plugins {
  id("com.intermedia.translations").version("<latest version>")
}

Then set it up:

import com.intermedia.translations.SupportedLanguages
import com.intermedia.translations.lokalise.LanguageMapping

translations {
  api {
    lokalise {
      apiToken = "<your lokalise api token>"
      projectId = "<your lokalise project id>"
      languageMappings = [
        new LanguageMapping("fr_CA", "fr"),
        new LanguageMapping("nl_NL", "nl"),
        new LanguageMapping("es_419", "es")
      ]
    }
  }
  supportedLanguages = new SupportedLanguages(
    ['de', 'es', 'fr', 'it', 'ja', 'nl'],
    ['en-rAU', 'en-rGB']
  )
  notTranslatedFile = file("./src/main/res/values/strings_not_translated.xml")
  resourcesFolder = file("./src/main/res/")
}

...

android {
    ...
}
  • api - it's a service used to download up-to-date translations
    • lokalise - Lokalise implementation. Plugin uses their download files API
      • apiToken - lokalise api token
      • projectId - lokalise project identifier
      • languageMappings - optional mapping for lokalise api language ISO names
  • supportedLanguages - list of supported languages in ISO format
  • notTranslatedFile - resources file with strings, which you added for future translating
  • resourcesFolder - folder which contains values-* folders with your local translations files

Plugin tasks

Pull new translations

To pull new translations run the task translationsPull:

./gradlew translationsPull

It will download fresh translations from the API, found new translations (based on strings from notTranslatedFile) and apply them.

Push new translations

TBD

Changelog

  • 0.0.1 - initial version

About

Translations gradle plugin automates work with lokalise translations in Android application sources.

Resources

License

Stars

Watchers

Forks

Languages