Class: Champollion::Translation
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Champollion::Translation
- Defined in:
- app/models/champollion/translation.rb
Class Method Summary collapse
Class Method Details
.all_translations ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/models/champollion/translation.rb', line 11 def self.all_translations # create empty hash for locales translation_hash = Hash.new { |k,v| k[v] = {} } # iterate through the translation records all.each do |translation| # get the key components key_scopes = translation.key.split(".") translation_hash[translation.locale.to_sym] ||= {} translation_hash[translation.locale.to_sym].merge!(key_scopes.reverse.inject(translation.value) {|a,n| { n.to_sym => a}}) end translation_hash end |