mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
25 lines
484 B
Ruby
25 lines
484 B
Ruby
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
|
|
|
|
|
|
private
|
|
|
|
@lock = Mutex.new
|
|
|
|
def self.supported_locales
|
|
@lock.synchronize do
|
|
@supported_locales ||= Dir.glob( File.join(Rails.root, 'config', 'locales', 'client.*.yml') ).map {|x| x.split('.')[-2]}.sort
|
|
end
|
|
end
|
|
end
|