我正在使用ResourceBundle
与各种*.properties
文件翻译 Java 应用程序。现在,我希望有一个 Gradle 任务,或者希望修改任务以通过将其替换为 ASCII 表示来自动转义任何 unicode 字符。像Java的native2ascii
工具那样。
这是我到目前为止使用构建文件完成的操作,但输出仍未转义:
import org.apache.tools.ant.filters.EscapeUnicode
tasks.withType(ProcessResources) {
filesMatching('**/*.properties') {
println "\t-> ${it}"
filter EscapeUnicode
}
}
感谢任何帮助。
答案 0 :(得分:4)
您可以通过以下方式为属性文件提供额外的复制规范:
import org.apache.tools.ant.filters.EscapeUnicode
tasks.withType(ProcessResources).each { task ->
task.from(task.getSource()) {
include '**/*.properties'
filter(EscapeUnicode)
}
}