提交 260390d0 编写于 作者: J Jesse Glick

Utility to move translations from one set of property files to another.

上级 fa3a82a9
// Usage: groovy move-l10n.groovy hudson/model/OldClass/old-view jenkins/model/NewClass/new-view 'Some\ Translatable\ Text'
def oldview = args[0];
def newview = args[1];
def key = args[2];
def scriptDir = new File(getClass().protectionDomain.codeSource.location.path).parent;
def resDir = new File(scriptDir, 'src/main/resources');
def basename = new File(resDir, oldview).name;
for (p in new File(resDir, oldview).parentFile.listFiles()) {
def n = p.name;
if (n == "${basename}.properties" || n.startsWith("${basename}_") && n.endsWith(".properties")) {
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)}
}
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册