Skip to content

Instantly share code, notes, and snippets.

@yu-tang
Last active November 19, 2015 20:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yu-tang/1a81901e0ea46ce30759 to your computer and use it in GitHub Desktop.
Save yu-tang/1a81901e0ea46ce30759 to your computer and use it in GitHub Desktop.
Enumerate filtered segments.
console.println 'Enumerate filtered segments.'
def entries = project.allEntries
def filter = editor.filter ?: [allowed: {true}]
def found = entries.findAll { filter.allowed it }
// Do something for each SourceTextEntry here
found.each {
// get translation info
def info = project.getTranslationInfo(it)
console.println "\n#${it.entryNum()}\t${it.srcText}"
console.println "\t${info.translation}"
console.println info.defaultTranslation ? '\t- Default' : "\t- Alternative\n\t $it.key" // key has more detail
}
"${found.size()} segments found."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment