mirror of
https://github.com/meineerde/redmine.git
synced 2026-03-11 19:53:07 +00:00
Add lang files completion rake task.
git-svn-id: http://redmine.rubyforge.org/svn/branches/work@1395 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
ba4ea8e2fd
commit
7980d34724
24
gloc-1.2.0/lib/tasks/gloc.rake
Normal file
24
gloc-1.2.0/lib/tasks/gloc.rake
Normal file
@ -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
|
||||
Loading…
x
Reference in New Issue
Block a user