Index: trunk/l10n-support/nn/skript/translation-graph.R =================================================================== --- trunk/l10n-support/nn/skript/translation-graph.R (revision 1547827) +++ trunk/l10n-support/nn/skript/translation-graph.R (revision 1547828) @@ -1,34 +1,39 @@ +#!/usr/bin/Rscript --vanilla +# Create graph showing which years the translators have been working on the translations. +# Uses data from a ‘translation-statistics.dat’ file. Don’t call this script directly; +# instead, use the ‘translation-statistics.sh’ script. + library(ggplot2) # Load graphing package. people=read.table("translation-statistics.dat", sep="\t", col.names=c("Number","Person","Year")) # Read translations statistics. # Sort graph first by last year the person worked, and then by the first year: people$Person=with(people,reorder(Person,Year,min)) # Second sort key: First year worked. people$Person=with(people,reorder(Person,Year,max)) # First sort key: Last year worked. # Save the plot. # You might want to play around with the ‘type’ and ‘antialias’ arguments to improve the rendering. png("translation-statistics.png",width=900,height=18*(length(unique(people$Person))+1)) # Could have used simply # qplot(Year, Person, data=people, geom="tile") # but let’s instead do some customising # to improve the look of the graph. ggplot(people, aes(x=Year,y=Person,label=Number)) + # Set up the graph. geom_vline(xintercept=seq(min(people$Year)-.5, max(people$Year)+.5), colour="grey90") + # Draw vertical lines for each year. geom_tile() + # Draw the boxes. geom_text(colour="white",size=4) + scale_x_continuous(breaks=unique(people$Year), # Show labels for *all* the years on the x-axis. expand=c(0,0)) + # Remove padding on the left and right of the graph. scale_y_discrete(expand=c(0,0))+ # Remove padding on the top and bottom of the graph. xlab(NULL) + ylab(NULL) + # Remove the axis labels. theme_bw(base_size=16) + # Remove the grey background. theme(panel.grid.major=element_blank(), # Remove the default grid lines, tick marks and border. panel.grid.minor=element_blank(), axis.ticks=element_blank(), panel.border=element_blank(), rect=element_blank()) dev.off() # Save the graph. Index: trunk/l10n-support/nn/skript/translation-statistics.sh =================================================================== --- trunk/l10n-support/nn/skript/translation-statistics.sh (revision 1547827) +++ trunk/l10n-support/nn/skript/translation-statistics.sh (revision 1547828) @@ -1,34 +1,34 @@ #!/bin/sh -# Create graph showing which year the translators have been working on translations. +# Create statistics file and graph showing which years the translators have been working on the translations. # Folder containing the PO files. folder="$1" # Explanation: # Find all the PO files. # Print only the author lines. # Print one line for each year the author has worked (assumes the ‘can_header’ sieve has already been run). # Print the lines on the format ‘AuthorYear’ (the ‘substr’ is just a hack to get rid of any trailing periods). # Filter out any ‘FIRST AUTHORYEAR’ entries. # Sort the entries. # Remove duplicate entries and calculate the number of times each ‘person-year’ occurs. # Replace space with tab as number–person seperator, and save the result. find "$folder" -name '*.po' \ | xargs grep -h '^# .*<.*@' \ | awk 'BEGIN {FS=","} { i=2; while (i<=NF){ print $1"\t"substr($i,1,5); i++ } }' \ | sed 's/^# //;s/ <[^>]\+>//' \ | grep -v 'FIRST AUTHOR' \ | sort \ | uniq -c \ | sed 's/ *\([^ ]\+\) /\1\t/' > translation-statistics.dat # Run an R script that generates the graph and saves it as ‘translation-statistics.png’. -Rscript translation-graph.R +./translation-graph.R # Optionally make the PNG more Web friendly with Adam7 interlacing. OPTIPNG=$(command -v optipng) OPTIPNG_EXISTS=$? if [ $OPTIPNG_EXISTS -eq 0 ] then $OPTIPNG -o9 -i1 translation-statistics.png fi