Class: Weatherman::I18N

Inherits:
Object
  • Object
show all
Defined in:
lib/yahoo_weatherman/i18n.rb

Overview

I18n

This class uses the locale files to translate the response sent from the Yahoo! Weather feed.

Constant Summary collapse

I18N_YAML_DIR =
File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'i18n'))
LANGUAGES =
{}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(language) ⇒ I18N

Expects a string with the locale file name. Eg. I18N.new('pt-br') will load the i18n/pt-br.yml file.


20
21
22
# File 'lib/yahoo_weatherman/i18n.rb', line 20

def initialize(language)
  @language = language
end

Instance Attribute Details

#languageObject

Returns the value of attribute language


14
15
16
# File 'lib/yahoo_weatherman/i18n.rb', line 14

def language
  @language
end

Instance Method Details

#translate!(attributes) ⇒ Object

Translates the messages in the response if a locale file was specified in the constructor. It modifies the hash passed in place.


28
29
30
31
32
33
34
35
# File 'lib/yahoo_weatherman/i18n.rb', line 28

def translate!(attributes)
  if i18n?
    translate_text! attributes
    translate_days! attributes
    translate_locations! attributes
  end
  attributes
end