Class: FastGettext::TranslationRepository::Yaml

Inherits:
Base
  • Object
show all
Defined in:
lib/fast_gettext/translation_repository/yaml.rb

Overview

Responsibility:

- find and store yaml files
- provide access to translations in yaml files

Instance Attribute Summary

Attributes inherited from Base

#name, #options

Instance Method Summary collapse

Methods inherited from Base

#[]

Constructor Details

#initialize(name, options = {}) ⇒ Yaml

Returns a new instance of Yaml.



10
11
12
13
# File 'lib/fast_gettext/translation_repository/yaml.rb', line 10

def initialize(name,options={})
  super
  reload
end

Instance Method Details

#available_localesObject



15
16
17
# File 'lib/fast_gettext/translation_repository/yaml.rb', line 15

def available_locales
  @files.keys
end

#plural(*keys) ⇒ Object



19
20
21
22
23
# File 'lib/fast_gettext/translation_repository/yaml.rb', line 19

def plural(*keys)
  ['one', 'other', 'plural2', 'plural3'].map do |name|
    self[yaml_dot_notation(keys.first, name)]
  end
end

#pluralisation_ruleObject



25
26
27
# File 'lib/fast_gettext/translation_repository/yaml.rb', line 25

def pluralisation_rule
  self['pluralisation_rule'] ? lambda{|n| eval(self['pluralisation_rule']) } : nil
end

#reloadObject



29
30
31
32
# File 'lib/fast_gettext/translation_repository/yaml.rb', line 29

def reload
  find_and_store_files(@options)
  super
end