Base
Responsibility:
- find and store yaml files - provide access to translations in yaml files
# File lib/fast_gettext/translation_repository/yaml.rb, line 15 def available_locales @files.keys end
# 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
# File lib/fast_gettext/translation_repository/yaml.rb, line 61 def add_yaml_key(result, prefix, hash) hash.each_pair do |key, value| if value.kind_of?(Hash) add_yaml_key(result, yaml_dot_notation(prefix, key), value) else result[yaml_dot_notation(prefix, key)] = value end end result end
# File lib/fast_gettext/translation_repository/yaml.rb, line 47 def current_translations @files[FastGettext.locale] || super end
# File lib/fast_gettext/translation_repository/yaml.rb, line 38 def find_and_store_files(options) @files = {} path = options[:path] || 'config/locales' Dir["#{path}/??.yml"].each do |yaml_file| locale = yaml_file.match(/([a-z]{2})\.yml$/)[1] @files[locale] = load_yaml(yaml_file, locale) end end
Given a yaml file return a hash of key -> translation
# File lib/fast_gettext/translation_repository/yaml.rb, line 52 def load_yaml(file, locale) yaml = YAML.load_file(file) yaml_hash_to_dot_notation(yaml[locale]) end
Generated with the Darkfish Rdoc Generator 2.