Module: WrfForecast::LocaleConfiguration

Defined in:
lib/wrf_forecast/locale_configuration.rb

Overview

This module loads and regulates the locale settings that are used to create the forecast

Class Method Summary collapse

Class Method Details

.change_locale(locale) ⇒ Object

module method to change the locale

Parameters:

  • locale (Symbol)

    the given locale symbol



18
19
20
21
# File 'lib/wrf_forecast/locale_configuration.rb', line 18

def self.change_locale(locale)
  I18n.locale = locale
  nil
end

.determine_locale(locale_string) ⇒ Object

module method to determine the correct locale from a given string

Parameters:

  • locale_string (String)

    the desired locale in its short string representation



25
26
27
28
29
30
31
32
33
# File 'lib/wrf_forecast/locale_configuration.rb', line 25

def self.determine_locale(locale_string)
  case locale_string
    when "de" then change_locale(:de)
    when "en" then change_locale(:en)
  else
    puts "Warning: found no match for locale #{locale_string}."
  end
  nil
end

.initialize_locale(locale_path) ⇒ Object

module method to load the locale files from the given path

Parameters:

  • locale_path (String)

    the directory with the locale files



10
11
12
13
14
# File 'lib/wrf_forecast/locale_configuration.rb', line 10

def self.initialize_locale(locale_path)
  I18n.load_path << Dir[File.expand_path(locale_path) + "/*.yml"]
  I18n.default_locale = :en
  nil
end