Module: Localized::Config

Defined in:
lib/localized/config.rb

Class Method Summary collapse

Class Method Details

.configurationObject



4
5
6
7
8
9
10
11
12
# File 'lib/localized/config.rb', line 4

def self.configuration
  @configuration ||= begin
    config_file = File.expand_path(File.join(Rails.root.to_s,'/config/localized.yml'))
    defaults_file = File.expand_path(File.join(__FILE__, '..', '..', '..', 'config/defaults.yml'))
    defaults = YAML.load_file(defaults_file)
    custom   = YAML.load_file(config_file) if File.exists?(config_file)
    symobolize_keys_and_values(defaults.merge(custom || {}))
  end.symbolize_keys
end

.default_host_prefixObject



14
15
16
# File 'lib/localized/config.rb', line 14

def self.default_host_prefix
  @default_host_prefix ||= self.configuration[:default_host_prefix].to_s
end

.default_localeObject



38
39
40
# File 'lib/localized/config.rb', line 38

def self.default_locale
  @default_locale ||= site_to_locale_map[default_site]
end

.default_siteObject



26
27
28
# File 'lib/localized/config.rb', line 26

def self.default_site
  @default_site ||= self.configuration[:default_site]
end

.locale_to_site_mapObject



22
23
24
# File 'lib/localized/config.rb', line 22

def self.locale_to_site_map
  @locale_to_site_map ||= site_to_locale_map.invert
end

.site_to_locale_mapObject



18
19
20
# File 'lib/localized/config.rb', line 18

def self.site_to_locale_map
  @site_to_locale_map ||= self.configuration[:site_locale_map].symbolize_keys
end

.supported_localesObject



34
35
36
# File 'lib/localized/config.rb', line 34

def self.supported_locales
  @supported_locales ||= site_to_locale_map.values.sort
end

.supported_sitesObject



30
31
32
# File 'lib/localized/config.rb', line 30

def self.supported_sites
  @supported_sites ||= site_to_locale_map.symbolize_keys.keys.sort
end