Module: Localyzed

Defined in:
lib/localyzed.rb,
lib/localyzed/base.rb,
lib/localyzed/version.rb

Defined Under Namespace

Modules: LocalyzedController Classes: Railtie

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.configure(config) ⇒ Object



3
4
# File 'lib/localyzed/base.rb', line 3

def self.configure(config)
end

.ensure_translations_file_exists(translations_file) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/localyzed/base.rb', line 11

def self.ensure_translations_file_exists translations_file
  translate_filepath = Rails.root.join(translations_file)
  unless File.exists?(translate_filepath)
    FileUtils.mkdir_p(File.dirname(translate_filepath))
    File.open(translate_filepath, 'a'){}
  end
  unless d = YAML::load_file(translate_filepath)
    I18n.available_locales.each do |l|
      d ||= {}.merge!({ :"#{l.to_s}" => {:routes => {}} } )
    end
    File.write(translate_filepath, d.to_yaml)
  end
end

.localyze_routes(translations_file, options = {}) ⇒ Object



6
7
8
9
# File 'lib/localyzed/base.rb', line 6

def self.localyze_routes(translations_file,options={})
  ensure_translations_file_exists(translations_file)
  ActionDispatch::Routing::Translator.translate_from_file(translations_file, options)
end