diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-02-21 15:11:09 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2009-02-21 15:11:09 +0000 |
commit | 1770fe54be14c2fc32e7d684501467860e3d827d (patch) | |
tree | c423ae381cfb2bce1bdb1363041cb78ba5fc6cfe /lib/tasks/locales.rake | |
parent | 1511b313776bbb710c21075013407429d37d4b40 (diff) | |
download | redmine-1770fe54be14c2fc32e7d684501467860e3d827d.tar.gz redmine-1770fe54be14c2fc32e7d684501467860e3d827d.zip |
Adds locales:update task as a replacement for gloc:update.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2501 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/tasks/locales.rake')
-rw-r--r-- | lib/tasks/locales.rake | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/tasks/locales.rake b/lib/tasks/locales.rake new file mode 100644 index 000000000..1ef997f69 --- /dev/null +++ b/lib/tasks/locales.rake @@ -0,0 +1,31 @@ +namespace :locales do + desc 'Updates language files based on en.yml content (only works for new top level keys).' + task :update do + dir = ENV['DIR'] || './config/locales' + + en_strings = YAML.load(File.read(File.join(dir,'en.yml')))['en'] + + files = Dir.glob(File.join(dir,'fr.{yaml,yml}')) + files.each do |file| + puts "Updating file #{file}" + file_strings = YAML.load(File.read(file)) + file_strings = file_strings[file_strings.keys.first] + + missing_keys = en_strings.keys - file_strings.keys + next if missing_keys.empty? + + puts "==> Missing #{missing_keys.size} keys (#{missing_keys.join(', ')})" + lang = File.open(file, 'a') + + missing_keys.each do |key| + {key => en_strings[key]}.to_yaml.each_line do |line| + next if line =~ /^---/ || line.empty? + puts " #{line}" + lang << " #{line}" + end + end + + lang.close + end + end +end |