1 module Radiant::AvailableLocales
2
3 # Returns the list of available locale files in options_for_select format.
4 #
5 def self.locales
6 available_locales = {}
7 Radiant.configuration.i18n.load_path.each do |path|
8 if File.exists?(path) && path !~ /_available_tags/
9 locale_yaml = YAML.load_file(path)
10 stem = File.basename(path, '.yml')
11 if locale_yaml[stem] && lang = locale_yaml[stem]["this_file_language"]
12 available_locales[lang] = stem
13 end
14 end
15 end
16 available_locales.collect {|k,v| [k, v]}.sort_by { |s| s[0] }
17 end
18
19 end