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