Sha256: 017c0db71701120660c3a6d593b6ce3461b12d4bc15fb038705abe92f1b04cf0

Contents?: true

Size: 462 Bytes

Versions: 56

Compression:

Stored size: 462 Bytes

Contents

require 'ostruct'

module I18n
  def self.name_for_locale(locale)
    begin
      I18n.backend.translate(locale, :name, :scope => [:language])
    rescue I18n::MissingTranslationData
      locale.to_s
    end
  end
  
  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
end

Version data entries

56 entries across 56 versions & 3 rubygems

Version Path
sunrise-cms-1.0.6 lib/sunrise/core_ext/i18n.rb
sunrise-cms-1.0.5 lib/sunrise/core_ext/i18n.rb
sunrise-cms-1.0.4 lib/sunrise/core_ext/i18n.rb
sunrise-cms-1.0.3 lib/sunrise/core_ext/i18n.rb
sunrise-cms-1.0.2 lib/sunrise/core_ext/i18n.rb
sunrise-cms-1.0.1 lib/sunrise/core_ext/i18n.rb
sunrise-cms-1.0.0 lib/sunrise/core_ext/i18n.rb
sunrise-cms-1.0.0.rc3 lib/sunrise/core_ext/i18n.rb
sunrise-cms-1.0.0.rc2 lib/sunrise/core_ext/i18n.rb
sunrise-cms-1.0.0.rc1 lib/sunrise/core_ext/i18n.rb
sunrise-cms-0.7.0.rc2 lib/sunrise/core_ext/i18n.rb
sunrise-cms-0.7.0.rc1 lib/sunrise/core_ext/i18n.rb
sunrise-cms-0.6.11 lib/sunrise/core_ext/i18n.rb
sunrise-cms-0.6.10 lib/sunrise/core_ext/i18n.rb
sunrise-cms-0.6.9 lib/sunrise/core_ext/i18n.rb
sunrise-cms-0.6.8 lib/sunrise/core_ext/i18n.rb
sunrise-cms-0.6.7 lib/sunrise/core_ext/i18n.rb
sunrise-cms-0.6.6 lib/sunrise/core_ext/i18n.rb
sunrise-cms-0.6.5 lib/sunrise/core_ext/i18n.rb
sunrise-cms-0.6.4 lib/sunrise/core_ext/i18n.rb