Module: I18n

Defined in:
lib/sunrise/core_ext/i18n.rb

Class Method Summary collapse

Class Method Details

.all_available_localesObject



12
13
14
15
16
17
18
19
20
# File 'lib/sunrise/core_ext/i18n.rb', line 12

def self.all_available_locales
  records = []
  
  available_locales.each do |locale|
    records << OpenStruct.new(:code => locale.to_s.downcase, :title => name_for_locale(locale))
  end
  
  records.sort_by(&:title)
end

.name_for_locale(locale) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/sunrise/core_ext/i18n.rb', line 4

def self.name_for_locale(locale)
  begin
    I18n.backend.translate(locale, :name, :scope => [:language])
  rescue I18n::MissingTranslationData
    locale.to_s
  end
end