提交 139c64b0 编写于 作者: J Jesse Glick

Ability to remove keys as well as move them.

上级 7bbf36b7
// Usage: groovy move-l10n.groovy hudson/model/OldClass/old-view jenkins/model/NewClass/new-view 'Some\ Translatable\ Text'
// (The new view may be given as '-' to simply delete the key.)
def oldview = args[0];
def newview = args[1];
......@@ -14,14 +15,18 @@ for (p in new File(resDir, oldview).parentFile.listFiles()) {
def lines = p.readLines('ISO-8859-1');
def matches = lines.findAll({it.startsWith("${key}=")});
if (!matches.isEmpty()) {
def nue = new File(resDir, newview + n.substring(basename.length()));
println("moving ${matches.size()} matches from ${n} to ${nue.name}");
lines.removeAll(matches);
p.withWriter('ISO-8859-1') {out ->
lines.each {line -> out.writeLine(line)}
}
nue.withWriterAppend('ISO-8859-1') {out ->
matches.each {line -> out.writeLine(line)}
if (newview == '-') {
println("deleting ${matches.size()} matches from ${n}");
} else {
def nue = new File(resDir, newview + n.substring(basename.length()));
println("moving ${matches.size()} matches from ${n} to ${nue.name}");
nue.withWriterAppend('ISO-8859-1') {out ->
matches.each {line -> out.writeLine(line)}
}
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册