Sha256: e90b4208613adf6a9c9937dc2bbb6e498806eacc5d65160775a429cdd85028dc

Contents?: true

Size: 745 Bytes

Versions: 38

Compression:

Stored size: 745 Bytes

Contents

# encoding: utf-8
#
class AvailableLanguage
  def self.all
    default = {"English" => "en", 'Português (Brasil)' => "pt-BR"}
    begin
      YAML.load_file("#{Rails.root.to_s}/config/available_language.yml")['locales'] || default
    rescue
      default
    end
  end

  def self.best_locale_for(lang)
    lang.gsub!('_', '-')
    locale = "en"
    if self.all.values.include? lang
      locale = lang 
    else
      self.all.values.each do |l|
        locale = l if l.gsub(/-.*/, '') == lang.gsub(/-.*/, '')
      end
    end
    locale
  end

  def self.default_locale
    default = "en"
    begin
      YAML.load_file("#{Rails.root.to_s}/config/available_language.yml")['default'] || default
    rescue
      default
    end
  end
  
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
iugusdk-1.0.0.alpha.23 app/models/available_language.rb
iugusdk-1.0.0.alpha.22 app/models/available_language.rb
iugusdk-1.0.0.alpha.21 app/models/available_language.rb
iugusdk-1.0.0.alpha.20 app/models/available_language.rb
iugusdk-1.0.0.alpha.19 app/models/available_language.rb
iugusdk-1.0.0.alpha.18 app/models/available_language.rb
iugusdk-1.0.0.alpha.17 app/models/available_language.rb
iugusdk-1.0.0.alpha.16 app/models/available_language.rb
iugusdk-1.0.0.alpha.14 app/models/available_language.rb
iugusdk-1.0.0.alpha.13 app/models/available_language.rb
iugusdk-1.0.0.alpha.12 app/models/available_language.rb
iugusdk-1.0.0.alpha.11 app/models/available_language.rb
iugusdk-1.0.0.alpha.10 app/models/available_language.rb
iugusdk-1.0.0.alpha.9 app/models/available_language.rb
iugusdk-1.0.0.alpha.7 app/models/available_language.rb
iugusdk-1.0.0.alpha.5 app/models/available_language.rb
iugusdk-1.0.0.alpha.4 app/models/available_language.rb
iugusdk-1.0.0.alpha.3 app/models/available_language.rb