我在一个应用程序上工作,在那里我们有不同的strings.xml文件在线翻译到众包翻译。翻译工具提供了用于访问每个URL的xml文件的API。
例如:https://localise.biz/api/export/locale/en.xml?format=android&key=7qUo-LUKd4VIHSwRYB5005T7QQbaFCGw
是否可以在gradle构建启动时下载并包含这些文件?
期待您的回答!
发布于 2019-12-23 04:53:01
IamAshKS给了我答案。我是这样解决的:
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 }}
}
}非常感谢你的帮助!现在,我只需要在实际构建之前运行它。
https://stackoverflow.com/questions/59340939
复制相似问题