Issue
I work on an app, where we have the different translations of the strings.xml file online to crowdsource translations. The translation tool offers an API for accessing the xml files per URL.
e.g.: https://localise.biz/api/export/locale/en.xml?format=android&key=7qUo-LUKd4VIHSwRYB5005T7QQbaFCGw
Is it possible to download and include those files when the gradle build starts?
Looking forward to your answers!
Solution
IamAshKS served me the answer. I solved it like this:
task downloadTranslations {
group 'pre-build tasks'
description 'Downloads all translation files when building the app.'
ext.apiKey = '7qUo-LUKd4VIHSwRYB5005T7QQbaFCGw'
//English
doLast {
def f = new File("${project.projectDir}/src/main/res/values/strings.xml")
new URL("https://localise.biz/api/export/locale/en.xml?format=android&key=${apiKey}").withInputStream{ i -> f.withOutputStream{ it << i }}
}
}
Thanks a lot for your help! Now, I only have to get it running before the actual build.
Answered By - ChilliBits
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.