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.11 app/models/available_language.rb
iugusdk-1.0.10 app/models/available_language.rb
iugusdk-1.0.9 app/models/available_language.rb
iugusdk-1.0.8 app/models/available_language.rb
iugusdk-1.0.7 app/models/available_language.rb
iugusdk-1.0.6 app/models/available_language.rb
iugusdk-1.0.5 app/models/available_language.rb
iugusdk-1.0.4 app/models/available_language.rb
iugusdk-1.0.3 app/models/available_language.rb
iugusdk-1.0.2 app/models/available_language.rb
iugusdk-1.0.1 app/models/available_language.rb
iugusdk-1.0.0.alpha.32 app/models/available_language.rb
iugusdk-1.0.0.alpha.31 app/models/available_language.rb
iugusdk-1.0.0.alpha.30 app/models/available_language.rb
iugusdk-1.0.0.alpha.29 app/models/available_language.rb
iugusdk-1.0.0.alpha.28 app/models/available_language.rb
iugusdk-1.0.0.alpha.27 app/models/available_language.rb
iugusdk-1.0.0.alpha.26 app/models/available_language.rb
iugusdk-1.0.0.alpha.25 app/models/available_language.rb
iugusdk-1.0.0.alpha.24 app/models/available_language.rb