From 7980d34724376fdf1ba7f62abbdf8623188e7202 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Thu, 1 May 2008 10:15:49 +0000 Subject: [PATCH] Add lang files completion rake task. git-svn-id: http://redmine.rubyforge.org/svn/branches/work@1395 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- gloc-1.2.0/lib/tasks/gloc.rake | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 gloc-1.2.0/lib/tasks/gloc.rake diff --git a/gloc-1.2.0/lib/tasks/gloc.rake b/gloc-1.2.0/lib/tasks/gloc.rake new file mode 100644 index 000000000..3eff3d419 --- /dev/null +++ b/gloc-1.2.0/lib/tasks/gloc.rake @@ -0,0 +1,24 @@ +namespace :gloc do + desc 'Updates language files based on em.yml content' + task :update do + dir = ENV['DIR'] || './lang' + + en_strings = {} + en_file = File.open(File.join(dir,'en.yml'), 'r') + en_file.each_line {|line| en_strings[$1] = $2 if line =~ %r{^([\w_]+):\s(.+)$} } + en_file.close + + files = Dir.glob(File.join(dir,'*.{yaml,yml}')) + files.each do |file| + puts "Updating file #{file}" + keys = IO.readlines(file).collect {|line| $1 if line =~ %r{^([\w_]+):\s(.+)$} }.compact + lang = File.open(file, 'a') + en_strings.each do |key, str| + next if keys.include?(key) + puts "added: #{key}" + lang << "#{key}: #{str}\n" + end + lang.close + end + end +end