Module: Radiant::AvailableLocales
- Defined in:
- lib/radiant/available_locales.rb
Overview
require_dependency ‘radiant/extension_loader’
Class Method Summary collapse
Class Method Details
.locale_paths ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/radiant/available_locales.rb', line 5 def self.locale_paths root_locales = [ Rails.root + 'config/locales' ] # unless root_locales.empty? # Radiant::ExtensionLoader.locale_paths.dup + root_locales # else # Radiant::ExtensionLoader.locale_paths # end end |
.locales ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/radiant/available_locales.rb', line 14 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 |