Skip to content
This repository
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 49 lines (34 sloc) 1.315 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
#!/bin/sh
exec scala -savecompiled "$0" "$@"
!#

import java.io._

val docs = new File(".").listFiles
  .filter(_.getName.endsWith(".textile")) // process only textile files
  .map(new DocumentationFile(_))

val translated = docs.filter(_.isTranslated) // only already translated files

val translatedLength = translated.map(_.length).sum
val docsLength = docs.map(_.length).sum

println(
  status("translated size", translatedLength, docsLength, (length) => asKB(length) )
)

println(
  status("translated files", translated.length, docs.length)
)

def status(
  title: String = "status",
  current: Long, total: Long,
  format: (Long) => String = (x) => x.toString): String = {

  val percent = current * 100 / total

  title + ": " + format(current) + "/" + format(total) + " " +
  percent + "%" +
  " (pending " + format(total - current) + " " +
  (100-percent) + "%)"
}

def asKB(length: Long) = (length / 1000) + "kb"

class DocumentationFile(val file: File) {

  val name = file.getName
  val length = file.length
  val isTranslated = (firstLine.indexOf("Esta página todavía no ha sido traducida al castellano") == -1)

  override def toString = "name: " + name + ", length: " + length + ", isTranslated: " + isTranslated

  def firstLine = new BufferedReader(new FileReader(file)).readLine

}
Something went wrong with that request. Please try again.