comparison lib/tasks/locales.rake @ 1298:4f746d8966dd redmine_2.3_integration

Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author Chris Cannam
date Fri, 14 Jun 2013 09:28:30 +0100
parents 622f24f53b42
children
comparison
equal deleted inserted replaced
1297:0a574315af3e 1298:4f746d8966dd
41 dir = ENV['DIR'] || './config/locales' 41 dir = ENV['DIR'] || './config/locales'
42 en_strings = YAML.load(File.read(File.join(dir,'en.yml')))['en'] 42 en_strings = YAML.load(File.read(File.join(dir,'en.yml')))['en']
43 files = Dir.glob(File.join(dir,'*.{yaml,yml}')) 43 files = Dir.glob(File.join(dir,'*.{yaml,yml}'))
44 files.sort.each do |file| 44 files.sort.each do |file|
45 puts "parsing #{file}..." 45 puts "parsing #{file}..."
46 file_strings = YAML.load(File.read(file)) 46 file_strings = YAML.load_file(file)
47 unless file_strings.is_a?(Hash)
48 puts "#{file}: content is not a Hash (#{file_strings.class.name})"
49 next
50 end
51 unless file_strings.keys.size == 1
52 puts "#{file}: content has multiple keys (#{file_strings.keys.size})"
53 next
54 end
47 file_strings = file_strings[file_strings.keys.first] 55 file_strings = file_strings[file_strings.keys.first]
48 56
49 file_strings.each do |key, string| 57 file_strings.each do |key, string|
50 next unless string.is_a?(String) 58 next unless string.is_a?(String)
51 string.scan /%\{\w+\}/ do |match| 59 string.scan /%\{\w+\}/ do |match|