Class: FastGettext::TranslationRepository::Yaml
- 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
Instance Method Summary collapse
- #available_locales ⇒ Object
-
#initialize(name, options = {}) ⇒ Yaml
constructor
A new instance of Yaml.
- #plural(*keys) ⇒ Object
- #pluralisation_rule ⇒ Object
- #reload ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(name, options = {}) ⇒ Yaml
Returns a new instance of Yaml.
12 13 14 15 |
# File 'lib/fast_gettext/translation_repository/yaml.rb', line 12 def initialize(name, = {}) super reload end |
Instance Method Details
#available_locales ⇒ Object
17 18 19 |
# File 'lib/fast_gettext/translation_repository/yaml.rb', line 17 def available_locales @files.keys end |
#plural(*keys) ⇒ Object
21 22 23 24 25 |
# File 'lib/fast_gettext/translation_repository/yaml.rb', line 21 def plural(*keys) ['one', 'other', 'plural2', 'plural3'].map do |name| self[yaml_dot_notation(keys.first, name)] end end |
#pluralisation_rule ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/fast_gettext/translation_repository/yaml.rb', line 27 def pluralisation_rule return unless rule = self['pluralisation_rule'] ->(n) do # rubocop:disable Lint/UnusedBlockArgument n can be used from pluralisation_rule code eval(rule) # rubocop:disable Security/Eval TODO remove eval end end |
#reload ⇒ Object
35 36 37 38 |
# File 'lib/fast_gettext/translation_repository/yaml.rb', line 35 def reload find_and_store_files(@options) super end |