1
|
|
2
|
require 'mycyma/info'
|
3
|
|
4
|
require 'ostruct'
|
5
|
require 'singleton'
|
6
|
require 'gettext'
|
7
|
|
8
|
module MyCyma
|
9
|
|
10
|
class Config < OpenStruct
|
11
|
include Singleton
|
12
|
include GetText
|
13
|
|
14
|
def initialize
|
15
|
str = File.read(File.join(RAILS_ROOT, "config", "settings.yml"))
|
16
|
conf_doc = YAML.load(str)
|
17
|
super(conf_doc)
|
18
|
end
|
19
|
|
20
|
def thumbnail_param_list
|
21
|
list = {}
|
22
|
self.thumbnail_sizes.each_pair do |name, params|
|
23
|
key = ("thumb_" + name).to_sym
|
24
|
list[key] = params
|
25
|
end
|
26
|
list
|
27
|
end
|
28
|
|
29
|
# should be guessed
|
30
|
def available_languages
|
31
|
{
|
32
|
'' => _("Browser preference"),
|
33
|
'en' => _("English"),
|
34
|
'fr' => _("French")
|
35
|
}
|
36
|
end
|
37
|
|
38
|
def switch_locale(locale = nil)
|
39
|
# if unspecified, use browser prefered langage
|
40
|
# (the new locale_rails handle this automagically by default)
|
41
|
set_locale(locale) unless locale.nil?
|
42
|
end
|
43
|
end
|
44
|
end
|
45
|
|