Sha256: 24ec7379e82d1f44003cefa52816c9ca288c07a076bcdc589c3d2e54459d91ce

Contents?: true

Size: 806 Bytes

Versions: 4

Compression:

Stored size: 806 Bytes

Contents

module Voicemail::LocalizationLoader

  def self.replace_config
    translation_keys.each { |key, value| override_config key, value }
  end

  #
  #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
  #
  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

  def self.translation_keys
    YAML.load(File.open("#{current_path}/../../templates/en.yml"))['en']['voicemail']
  end

  def self.current_path
    File.expand_path File.dirname(__FILE__)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
voicemail-1.1.1 lib/voicemail/localization_loader.rb
voicemail-1.1.0 lib/voicemail/localization_loader.rb
voicemail-1.0.0 lib/voicemail/localization_loader.rb
voicemail-1.0.0.beta lib/voicemail/localization_loader.rb