pull/6827/head
parent
53db8dceb3
commit
c54df57954
@ -0,0 +1,33 @@ |
||||
#!/usr/bin/env ruby |
||||
|
||||
require 'yaml' |
||||
|
||||
langdir = File.dirname(__FILE__) |
||||
|
||||
template_file = "#{langdir}/en.yml" |
||||
template = YAML::load_file(template_file)['en'] |
||||
|
||||
errors = false |
||||
|
||||
Dir.glob("#{langdir}/*.yml").each {|lang_file| |
||||
next if lang_file == template_file |
||||
|
||||
lang = YAML::load_file(lang_file) |
||||
l = lang.keys[0] |
||||
|
||||
template.each_pair {|key, txt| |
||||
if ! lang[l][key] |
||||
puts "missing: ${l}: #{key}" |
||||
errors = true |
||||
end |
||||
} |
||||
|
||||
lang[l].keys.each {|k| |
||||
if !template[k] |
||||
puts "obsolete: #{l}: #{k}" |
||||
errors = true |
||||
end |
||||
} |
||||
} |
||||
|
||||
puts "All OK!" unless errors |
@ -1,31 +0,0 @@ |
||||
desc 'Update translation files' |
||||
|
||||
require 'yaml' |
||||
|
||||
namespace :redmine do |
||||
namespace :backlogs do |
||||
task :update_translations => :environment do |
||||
langdir = File.dirname(File.dirname(File.dirname(__FILE__))) + '/config/locales' |
||||
template_file = "#{langdir}/en.yml" |
||||
template = YAML::load_file(template_file)['en'] |
||||
|
||||
Dir.glob("#{langdir}/*.yml").each {|lang_file| |
||||
next if lang_file == template_file |
||||
lang = YAML::load_file(lang_file) |
||||
l = lang.keys[0] |
||||
|
||||
template.each_pair {|key, txt| |
||||
next if lang[l][key] |
||||
lang[l][key] = "[[#{txt}]]" |
||||
} |
||||
lang[l].keys.each {|k| |
||||
lang[l].delete(k) unless template[k] |
||||
} |
||||
|
||||
File.open( lang_file, 'w' ) do |out| |
||||
YAML.dump(lang, out) |
||||
end |
||||
} |
||||
end |
||||
end |
||||
end |
Loading…
Reference in new issue