9 public :translations, :init_translations
17 def initialize(locale)
18 @locale = locale.to_sym
21 @reference = I18n.backend.translations[:'en']
22 @data = I18n.backend.translations[@locale]
24 @result = {:bogus => [], :missing => [], :pluralization => []}
29 compare :missing, @reference, @data
30 compare :bogus, @data, @reference
34 [:missing, :bogus, :pluralization].each do |direction|
35 next unless result[direction].size > 0
38 puts "\nThe following pluralization keys seem to differ:"
40 puts "\nThe following keys seem to be #{direction} for #{@locale.inspect}:"
42 puts ' ' + result[direction].join("\n ")
44 if result.map{|k, v| v.size == 0}.uniq == [true]
45 puts "No inconsistencies found."
52 def compare(direction, reference, data)
53 reference.each do |key, value|
57 compare direction, value, (namespace?(data[key]) ? data[key] : {})
58 elsif pluralization?(value)
59 compare :pluralization, value, (pluralization?(data[key]) ? data[key] : {})
63 @result[direction] << current_key(key)
69 (@key_stack.dup << key).join('.')
73 Hash === hash and !pluralization?(hash)
76 def pluralization?(hash)
77 Hash === hash and hash.has_key?(:one) and hash.has_key?(:other)
83 rails/active_record.yml
84 rails/active_support.yml
86 I18n.load_path += Dir["locale/#{@locale}.{rb,yml}"]
87 I18n.backend.init_translations