discourse/app/models/locale_site_setting.rb

25 lines
515 B
Ruby
Raw Normal View History

require_dependency 'enum_site_setting'
class LocaleSiteSetting < EnumSiteSetting
def self.valid_value?(val)
supported_locales.include?(val)
end
def self.values
supported_locales.map do |l|
{name: l, value: l}
end
end
@lock = Mutex.new
def self.supported_locales
@lock.synchronize do
2013-06-13 11:46:20 -04:00
@supported_locales ||= Dir.glob( File.join(Rails.root, 'config', 'locales', 'client.*.yml') ).map {|x| x.split('.')[-2]}.sort
end
end
private_class_method :supported_locales
end