Sha256: 8ec444797d7d70a6216430a7b6e2a8dcc86560eb7434e3440128624ed1348c6a

Contents?: true

Size: 985 Bytes

Versions: 7

Compression:

Stored size: 985 Bytes

Contents

module Radiant::AvailableLocales
  
  def self.locale_paths
    root_locales = [File.join(RADIANT_ROOT, 'config', 'locales'), File.join(RAILS_ROOT, 'config', 'locales')].uniq
    unless root_locales.empty?
      Radiant::ExtensionLoader.locale_paths.dup + root_locales
    else
      Radiant::ExtensionLoader.locale_paths
    end
  end
    
  def self.locales
    available_locales = {}
    
    locale_paths.each do |path|    
      if File.exists? path
        Dir.new(path).entries.collect do |x|
          result = x =~ /\.yml/ ? x.sub(/\.yml/,"") : nil
          # filters out the available_tags files
          result =~ /\_available_tags/ ? nil : result
        end.compact.each do |str|
          locale_file = YAML.load_file(path + "/" + str + ".yml")
          lang = locale_file[str]["this_file_language"] if locale_file[str]
          available_locales.merge! Hash[lang, str] if lang
        end.freeze
      end
    end
    available_locales.sort_by{ |s| s[0] }
  end

end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
radiantcms-couchrest_model-0.1.4 lib/radiant/available_locales.rb
radiantcms-couchrest_model-0.1.3 lib/radiant/available_locales.rb
radiantcms-couchrest_model-0.1.2 lib/radiant/available_locales.rb
radiantcms-couchrest_model-0.1.1 lib/radiant/available_locales.rb
radiantcms-couchrest_model-0.1 lib/radiant/available_locales.rb
radiant-0.9.1 lib/radiant/available_locales.rb
radiant-0.9.0.rc2 lib/radiant/available_locales.rb