Skip to content

Instantly share code, notes, and snippets.

@olshevski
Last active December 14, 2019 13:01
Show Gist options
  • Save olshevski/c82aa02d3977eb49555d88390c46982f to your computer and use it in GitHub Desktop.
Save olshevski/c82aa02d3977eb49555d88390c46982f to your computer and use it in GitHub Desktop.
final String TWINE_INPUT_FILE = "${projectDir}/translations/twine.txt"
final String TWINE_OUTPUT_DIR = "${projectDir}/build/generated/twine"
android.applicationVariants.all { variant ->
variant.registerGeneratedResFolders(files(TWINE_OUTPUT_DIR))
}
task generateLocalizations {
description "Generates localizations from twine.txt file."
inputs.file(TWINE_INPUT_FILE)
outputs.dir(TWINE_OUTPUT_DIR)
doLast {
String resourceFolder = "${TWINE_OUTPUT_DIR}/values"
mkdir resourceFolder
exec {
commandLine 'bundle', 'exec', 'twine', 'generate-localization-file',
TWINE_INPUT_FILE, "${resourceFolder}/generated_strings.xml",
'--format', 'android', '--lang', 'en'
}
}
}
preBuild.dependsOn generateLocalizations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment