Module: SurveyorParserSurveyTranslationMethods

Defined in:
lib/surveyor/parser.rb

Overview

SurveySection model

Instance Method Summary collapse

Instance Method Details

#parse_and_build(context, args, original_method, reference_identifier) ⇒ Object



191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/surveyor/parser.rb', line 191

def parse_and_build(context, args, original_method, reference_identifier)
  dir = Surveyor::Parser.options[:filename].nil? ? Dir.pwd : File.dirname(Surveyor::Parser.options[:filename])
  # build, no change in context
  args[0].each do |k,v|
    case v
    when Hash
      trans = YAML::dump(v)
    when String
      trans = File.read(File.join(dir,v))
    when :default
      trans = YAML::dump({})
    end
    context[:survey].translations << self.class.new(:locale => k.to_s, :translation => trans)
  end
end