GitLab ist wegen Wartungsarbeiten am Montag, den 10. Mai, zwischen 17:00 und 19:00 Uhr nicht erreichbar.

Commit cae73b79 authored by jplang's avatar jplang

Adds locales:update task as a replacement for gloc:update.

git-svn-id: https://svn.redmine.org/redmine/trunk@2501 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 88e80631
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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment