Sha256: 4cf3d57a6edd6ae48441fe23a70eb09eaf52df7fbeb2bf662617815d0aa261bb

Contents?: true

Size: 966 Bytes

Versions: 2

Compression:

Stored size: 966 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.glob(path + "/*.yml").collect do |x|
          result = File.basename(x, ".yml")
          # filters out the available_tags files
          result =~ /\_available_tags/ ? nil : result
        end.compact.each do |str|
          locale_file = YAML.load_file(File.join(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

2 entries across 2 versions & 1 rubygems

Version Path
radiant-1.0.0.rc2 lib/radiant/available_locales.rb
radiant-1.0.0.rc1 lib/radiant/available_locales.rb