Module: Voicemail::LocalizationLoader
- Defined in:
- lib/voicemail/localization_loader.rb
Class Method Summary collapse
- .current_path ⇒ Object
-
.override_config(key, value) ⇒ Object
This method scans the keys in the template en.yml - it doesn’t use any values, it just sets up methods to call i18n.translate later.
- .replace_config ⇒ Object
- .translation_keys ⇒ Object
Class Method Details
.current_path ⇒ Object
25 26 27 |
# File 'lib/voicemail/localization_loader.rb', line 25 def self.current_path File. File.dirname(__FILE__) end |
.override_config(key, value) ⇒ Object
This method scans the keys in the template en.yml - it doesn’t use any values, it just sets up methods to call i18n.translate later
11 12 13 14 15 16 17 18 19 |
# File 'lib/voicemail/localization_loader.rb', line 11 def self.override_config(key, value) if value.class == String Voicemail::Plugin.config[key.to_sym] = Proc.new { I18n.t "voicemail.#{key}" } else value.keys.each do |k, v| Voicemail::Plugin.config[key.to_sym][k.to_sym] = Proc.new { I18n.t("voicemail.#{key}.#{k}") } end end end |
.replace_config ⇒ Object
3 4 5 |
# File 'lib/voicemail/localization_loader.rb', line 3 def self.replace_config translation_keys.each { |key, value| override_config key, value } end |
.translation_keys ⇒ Object
21 22 23 |
# File 'lib/voicemail/localization_loader.rb', line 21 def self.translation_keys YAML.load(File.open("#{current_path}/../../templates/en.yml"))['en']['voicemail'] end |