ref: refs/heads/backgroud_patches_bnc550934 commit fec94faa8960f68547a1980ff6d4df634e31dd57 Author: Stefan Schubert <schubi@suse.de> Date: Fri Nov 20 19:15:02 2009 +0100 evaluate the state of each translation and suggest to delete it if it is unsufficent --- Rakefile | 24 ++++++++++++++++++++++++ webclient/lib/tasks/gettext.rake | 27 +++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 0 deletions(-) diff --git a/Rakefile b/Rakefile index 184c6cf..a1b8f72 100644 --- a/Rakefile +++ b/Rakefile @@ -8,12 +8,36 @@ task :default => :test %w(fetch_po makemo updatepot test test:ui rdoc pgem package release install install_policies check_syntax package-local buildrpm buildrpm-local test:test:rcov).each do |task_name| desc "Run #{task_name} task for all projects" + task task_name do + if task_name == "fetch_po" + #remove translation statistik + File.delete(File.join("pot", "translation_status.yaml")) if File.exist?("pot/translation_status.yaml") + end + PROJECTS.each do |project| system %(cd #{project} && #{env} #{$0} #{task_name}) raise "Error on execute task #{task_name} on #{project}" if $?.exitstatus != 0 end + + if task_name == "fetch_po" + #remove translations which have not at least 80 percent translated text + limit = Float(80) + result = Hash.new + result = YAML.load(File.open(File.join("pot", "translation_status.yaml"))) if File.exists?(File.join("pot", "translation_status.yaml")) + result.each {|key,value| + translated = un_translated = Float(0) + translated = value["translated"].to_f if value.has_key? "translated" + un_translated += value["untranslated"].to_f if value.has_key? "untranslated" + un_translated += value["fuzzy"].to_f if value.has_key? "fuzzy" + limit_eval = translated/(un_translated+translated) + if limit_eval < limit/100 + puts "Language #{key} should be deleted cause it has only #{(limit_eval*100).to_i} percent translation reached." + end + } + end end + end desc "Run doc to generate whole documentation" diff --git a/webclient/lib/tasks/gettext.rake b/webclient/lib/tasks/gettext.rake index 972de14..d0a00dc 100644 --- a/webclient/lib/tasks/gettext.rake +++ b/webclient/lib/tasks/gettext.rake @@ -51,5 +51,32 @@ task :fetch_po, [:lcn_dir] do |t, args| FileUtils.cp(po_file, destfile) end } + result = Hash.new() + destdir = File.join(File.dirname(__FILE__),"../../..", "pot") + Dir.mkdir destdir unless File.directory?(destdir) + result = YAML.load(File.open(File.join(destdir, "translation_status.yaml"))) if File.exists?(File.join(destdir, "translation_status.yaml")) + + Dir.glob("{po}/**/*.po").each {|po_file| + output = `LANG=C msgfmt -o /dev/null -c -v --statistics #{po_file} 2>&1` + language = File.basename(File.dirname(po_file)) + output.split(",").each {|column| + value = column.split(" ") + if value.size > 2 + unless result[language].blank? + unless result[language][value[1]].blank? + result[language][value[1]] += value[0].to_i + else + result[language][value[1]] = value[0].to_i + end + else + result[language] = Hash.new + result[language][value[1]] = value[0].to_i + end + end + } + } + f = File.open(File.join(destdir, "translation_status.yaml"), "w") + f.write(result.to_yaml) + f.close end -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org