3 # Generate statistics of Amarok's localizations
5 # Copyright (C) 2007 Harald Sitter <sitter.harald@gmail.com>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 puts "generate_l10nstats.rb [amarokversion]"
34 @file = "../amarok-#{@version}.html"
40 def calcpercentage( per )
42 @cper = ((@cper + per) / 2)
48 # write HTML header part
51 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
54 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
55 <title>Statistics of Amarok #{@version} translations</title>
60 <a name="statistics of amarok #{@version} translations">
61 <h1>Statistics of Amarok #{@version} translations</h1><br>
62 <table border="1" cellspacing="0"dir="ltr">
64 <td align="left" valign="middle" width="60" height="12">
65 <font color="#196aff"><i><b>Language</b></i></font>
67 <td align="center" valign="middle" width="142" height="12">
68 <font color="#196aff"><i><b>Fuzzy Strings</b></i></font>
70 <td align="center" valign="middle" width="168" height="12">
71 <font color="#196aff"><i><b>Untranslated Strings</b></i></font>
73 <td align="center" valign="middle" width="163" height="12">
74 <font color="#196aff"><i><b>All Not Shown Strings</b></i></font>
76 <td align="center" valign="middle" width="163" height="12">
77 <font color="#196aff"><i><b>Translated %</b></i></font>
82 # write HTML footer part
86 <td align="left" valign="middle" width="60" height="12">
87 <u><i><b>#{@clang}</b></i></u>
89 <td align="center" valign="middle" width="142" height="12">
91 #{if @cfuzzy == "0" then
98 <td align="center" valign="middle" width="168" height="12">
100 #{if @cuntrans == "0" then
107 <td align="center" valign="middle" width="163" height="12">
109 #{if @cnotshow == "0" then
116 <td align="center" valign="middle" width="163" height="12">
118 #{if @cper == "0" then
131 if lang != "." and lang != ".." then
132 Dir.chdir("po/#{lang}")
134 # grab statistics data
135 `msgfmt --statistics amarok.po 2> tmp.txt`
137 File.delete("tmp.txt")
139 # rape the data and create some proper variables
140 values = term.scan(/[\d]+/)
141 notshow = values[1].to_i + values[2].to_i
142 all = values[0].to_i + values[1].to_i + values[2].to_i
144 per = ((100.0 * show.to_f) / all.to_f)
146 # assign font colors according to translation status
147 # TODO: replace with case -> point out how to do with relational operators
149 fcolor = "#00B015" #green
151 fcolor = "#FF9900" #orange
153 fcolor = "#6600FF" #blue
155 fcolor = "#000000" #black
157 fcolor = "#FF0000" #red
164 <td align="left" valign="middle" width="60" height="12">
165 <font color="#{fcolor}">
169 <td align="center" valign="middle" width="142" height="12">
170 <font color="#{fcolor}">
171 #{if values[1] == nil then
178 <td align="center" valign="middle" width="168" height="12">
179 <font color="#{fcolor}">
180 #{if values[2] == nil then
187 <td align="center" valign="middle" width="163" height="12">
188 <font color="#{fcolor}">
189 #{if notshow == nil then
196 <td align="center" valign="middle" width="163" height="12">
197 <font color="#{fcolor}">
207 # update countin variables
208 @cfuzzy += values[1].to_i
209 @cuntrans += values[2].to_i
210 @cnotshow += notshow.to_i
212 calcpercentage( per.to_i )
217 puts "Untaring the tarball..."
218 `tar -xf amarok-#{@version}.tar.bz2`
219 Dir.chdir("amarok-#{@version}")
220 File.delete("po/Makefile.am", "po/Makefile.in")
223 puts "Writing the header..."
226 puts "Writing the statistics..."
227 langs = Dir.entries("po")
228 Dir.foreach("po") {|lang|
232 puts "Writing the footer..."
235 puts "Cleaning up..."
237 FileUtils.rm_r( "amarok-#{@version}" )
239 puts "Generation finished..."