Module: I18nPlus

Defined in:
lib/i18n_plus/state.rb,
lib/i18n_plus/locale.rb,
lib/i18n_plus/country.rb,
lib/i18n_plus/version.rb,
lib/i18n_plus/currency.rb,
lib/i18n_plus/language.rb

Constant Summary collapse

STATES =
::YAML.load(File.open(data_path.join("states.yml")))
LOCALES =
::YAML.load(File.open(data_path.join("locales.yml")))
COUNTRIES =
::YAML.load(File.open(data_path.join("countries.yml")))
VERSION =
"0.6.2"
CURRENCIES =
::YAML.load(File.open(data_path.join("currencies.yml")))
LANGUAGES =
::YAML.load(File.open(data_path.join("languages.yml")))

Class Method Summary collapse

Class Method Details

.countries(*args) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/i18n_plus/country.rb', line 7

def self.countries(*args)
  options = args.extract_options!
  locale = (options[:locale] || I18n.locale || I18n.default_locale || :en).to_s[0..1].downcase
  # Fallback to English if we don't use English or German
  locale = 'en' unless ['de', 'en'].include?(locale)
  COUNTRIES[locale]
end

.country_name(code, *args) ⇒ Object



15
16
17
# File 'lib/i18n_plus/country.rb', line 15

def self.country_name(code, *args)
  countries(*args)[code.to_s.upcase]
end

.currencies(*args) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/i18n_plus/currency.rb', line 7

def self.currencies(*args)
  options = args.extract_options!
  locale = (options[:locale] || I18n.locale || I18n.default_locale || :en).to_s[0..1].downcase
  # Fallback to English if we don't use English or German
  locale = 'en' unless ['de', 'en'].include?(locale)
  CURRENCIES[locale]
end

.currency_name(code, *args) ⇒ Object



15
16
17
# File 'lib/i18n_plus/currency.rb', line 15

def self.currency_name(code, *args)
  currencies(*args)[code.to_s.upcase]
end

.language_name(code, *args) ⇒ Object



15
16
17
# File 'lib/i18n_plus/language.rb', line 15

def self.language_name(code, *args)
  languages(*args)[code.to_s.upcase]
end

.languages(*args) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/i18n_plus/language.rb', line 7

def self.languages(*args)
  options = args.extract_options!
  locale = (options[:locale] || I18n.locale || I18n.default_locale || :en).to_s[0..1].downcase
  # Fallback to English if we don't use English or German
  locale = 'en' unless ['de', 'en'].include?(locale)
  LANGUAGES[locale]
end

.locale_name(code, *args) ⇒ Object



15
16
17
# File 'lib/i18n_plus/locale.rb', line 15

def self.locale_name(code, *args)
  locales(*args)[code.to_s]
end

.locales(*args) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/i18n_plus/locale.rb', line 7

def self.locales(*args)
  options = args.extract_options!
  locale = (options[:locale] || I18n.locale || I18n.default_locale || :en).to_s[0..1].downcase
  # Fallback to English if we don't use English or German
  locale = 'en' unless ['de', 'en'].include?(locale)
  LOCALES[locale]
end

.state_name(country_code, state_code, *args) ⇒ Object



15
16
17
# File 'lib/i18n_plus/state.rb', line 15

def self.state_name(country_code, state_code, *args)
  states(country_code, *args)[code.to_s.upcase]
end

.states(country_code, *args) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/i18n_plus/state.rb', line 7

def self.states(country_code, *args)
  options = args.extract_options!
  locale = (options[:locale] || I18n.locale || I18n.default_locale || :en).to_s[0..1].downcase
  # Fallback to English if we don't use English or German
  locale = 'en' unless ['de', 'en'].include?(locale)
  STATES[locale][country_code.to_s.upcase]
end