Class: Localeapp::MissingTranslations
- Inherits:
-
Object
- Object
- Localeapp::MissingTranslations
- Defined in:
- lib/localeapp/missing_translations.rb
Class Attribute Summary collapse
-
.cached_keys ⇒ Object
Returns the value of attribute cached_keys.
Instance Method Summary collapse
- #[](locale) ⇒ Object
- #add(locale, key, description = nil, options = {}) ⇒ Object
-
#initialize ⇒ MissingTranslations
constructor
A new instance of MissingTranslations.
- #to_send ⇒ Object
Constructor Details
#initialize ⇒ MissingTranslations
Returns a new instance of MissingTranslations.
11 12 13 |
# File 'lib/localeapp/missing_translations.rb', line 11 def initialize @translations = Hash.new { |h, k| h[k] = {} } end |
Class Attribute Details
.cached_keys ⇒ Object
Returns the value of attribute cached_keys.
8 9 10 |
# File 'lib/localeapp/missing_translations.rb', line 8 def cached_keys @cached_keys end |
Instance Method Details
#[](locale) ⇒ Object
23 24 25 |
# File 'lib/localeapp/missing_translations.rb', line 23 def [](locale) @translations[locale] end |
#add(locale, key, description = nil, options = {}) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/localeapp/missing_translations.rb', line 15 def add(locale, key, description = nil, = {}) separator = .delete(:separator) { I18n.default_separator } scope = .delete(:scope) key = I18n.normalize_keys(nil, key, scope, separator).map(&:to_s).join(separator) record = MissingTranslationRecord.new(key, locale, description, ) @translations[locale][key] = record end |
#to_send ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/localeapp/missing_translations.rb', line 27 def to_send data = [] # need the sort to make specs work under 1.8 @translations.sort { |a, b| a.to_s <=> b.to_s }.each do |locale, records| records.each do |key, record| next if cached?(key) cache(key) missing_data = {:key => key, :locale => locale, :options => record.} missing_data[:description] = record.description if record.description data << missing_data end end data end |