Class: Translator::Yaml

Inherits:
Base
  • Object
show all
Defined in:
lib/translator.rb

Constant Summary

Constants included from Support

Support::LOCALES

Instance Attribute Summary

Attributes inherited from Base

#destination, #source

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#all_keys, all_source_files, #clear_all_keys, #copy_and_translate_line, #copy_lines_to_all_locales, #each_line, #initialize, #new_translation_message, #non_english_locales, #non_us_locales, #post_process, #pre_process, #translate, #translate_key, #translate_new_key, #write_content

Constructor Details

This class inherits a constructor from Translator::Base

Class Method Details

.templateObject



228
229
230
# File 'lib/translator.rb', line 228

def self.template
  Yaml
end

Instance Method Details

#comment?(line) ⇒ Boolean

Returns:

  • (Boolean)


248
249
250
# File 'lib/translator.rb', line 248

def comment?(line)
  line =~ /^#/
end

#format(key, value) ⇒ Object



236
237
238
# File 'lib/translator.rb', line 236

def format(key, value)
  "#{key}: #{value}"
end

#key_and_value_from_line(line) ⇒ Object



240
241
242
243
244
245
246
# File 'lib/translator.rb', line 240

def key_and_value_from_line(line)
  if line =~ /^([^\:]+):(.*)/
    return $1, $2.strip
  else
    return nil, nil
  end
end

#parse_template(path) ⇒ Object



232
233
234
# File 'lib/translator.rb', line 232

def parse_template(path)
  YAML.load_file(path)
end