ref: refs/heads/backgroud_patches_bnc550934
commit 1a2a92a6252478730fd3d7e6f0be5c35e2d44663
Author: Stefan Schubert
Date: Mon Nov 23 13:57:01 2009 +0100
moved fetch_po to an own task in the top level Rakefile
---
Rakefile | 84 ++++++++++++++++++++++++++------------
webclient/lib/tasks/gettext.rake | 27 ------------
2 files changed, 58 insertions(+), 53 deletions(-)
diff --git a/Rakefile b/Rakefile
index 21f8667..042a48c 100644
--- a/Rakefile
+++ b/Rakefile
@@ -8,42 +8,74 @@ desc 'Run all tests by default'
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|
+%w(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
- #remove translation statistik
- File.delete(File.join("pot", "translation_status.yaml")) if task_name == "fetch_po" && File.exist?("pot/translation_status.yaml")
-
PROJECTS.each do |project|
system %(cd #{project} && #{env} #{$0} #{task_name})
raise "Error on execute task #{task_name} on #{project}" if $?.exitstatus != 0
end
+ end
+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."
- Dir.glob("**/#{key}/").each {|po_dir|
- unless po_dir.include? "lang_helper" #do not delete translations for language selections
-# puts "deleting #{po_dir}"
-# remove_dir(po_dir, true) #force=true
+desc "Fetch po files from lcn. Parameter: source directory of lcn e.g. ...lcn/trunk/webyast/"
+task :fetch_po, [:lcn_dir] do |t, args|
+ args.with_defaults(:lcn_dir => File.join(File.dirname(__FILE__),"../../", "lcn", "trunk","webyast"))
+ #remove translation statistik
+ File.delete(File.join("pot", "translation_status.yaml")) if File.exist?("pot/translation_status.yaml")
+ result = Hash.new()
+
+ PROJECTS.each do |project|
+ system %(cd #{project} && #{env} #{$0} fetch_po #{args.lcn_dir})
+ raise "Error on execute task fetch_po on #{project}" if $?.exitstatus != 0
+
+ #collecting translation information
+ Dir.glob("#{project}/**/*.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
+ if result.has_key? language
+ if result[language].has_key? value[1]
+ result[language][value[1]] += value[0].to_i
+ else
+ result[language][value[1]] = value[0].to_i
end
- }
- end
- }
- end
+ else
+ result[language] = Hash.new
+ result[language][value[1]] = value[0].to_i
+ end
+ end
+ }
+ }
end
+
+ #saving result to pot/translation_status.yaml
+ destdir = File.join(File.dirname(__FILE__), "pot")
+ Dir.mkdir destdir unless File.directory?(destdir)
+ f = File.open(File.join(destdir, "translation_status.yaml"), "w")
+ f.write(result.to_yaml)
+ f.close
+ #remove translations which have not at least 80 percent translated text
+ limit = Float(80)
+ 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."
+ Dir.glob("**/#{key}/").each {|po_dir|
+ unless po_dir.include? "lang_helper" #do not delete translations for language selections
+# puts "deleting #{po_dir}"
+# remove_dir(po_dir, true) #force=true
+ 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 d0a00dc..972de14 100644
--- a/webclient/lib/tasks/gettext.rake
+++ b/webclient/lib/tasks/gettext.rake
@@ -51,32 +51,5 @@ 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