class Twine::Formatters::Flash

Public Instance Methods

default_file_name() click to toggle source
# File lib/twine/formatters/flash.rb, line 14
def default_file_name
  'resources.properties'
end
extension() click to toggle source
# File lib/twine/formatters/flash.rb, line 10
def extension
  '.properties'
end
format_comment(definition, lang) click to toggle source
# File lib/twine/formatters/flash.rb, line 52
def format_comment(definition, lang)
  "# #{definition.comment}\n" if definition.comment
end
format_header(lang) click to toggle source
# File lib/twine/formatters/flash.rb, line 44
def format_header(lang)
  "## Flash Strings File\n## Generated by Twine #{Twine::VERSION}\n## Language: #{lang}"
end
format_name() click to toggle source
# File lib/twine/formatters/flash.rb, line 6
def format_name
  'flash'
end
format_section_header(section) click to toggle source
# File lib/twine/formatters/flash.rb, line 48
def format_section_header(section)
  "## #{section.name} ##\n"
end
format_sections(twine_file, lang) click to toggle source
# File lib/twine/formatters/flash.rb, line 40
def format_sections(twine_file, lang)
  super + "\n"
end
format_value(value) click to toggle source
# File lib/twine/formatters/flash.rb, line 60
def format_value(value)
  convert_placeholders_from_twine_to_flash(value)
end
key_value_pattern() click to toggle source
# File lib/twine/formatters/flash.rb, line 56
def key_value_pattern
  "%{key}=%{value}"
end
read(io, lang) click to toggle source
# File lib/twine/formatters/flash.rb, line 23
def read(io, lang)
  last_comment = nil
  while line = io.gets
    match = /((?:[^"\\]|\\.)+)\s*=\s*((?:[^"\\]|\\.)*)/.match(line)
    if match
      key = match[1]
      value = match[2].strip

      set_translation_for_key(key, lang, value)
      set_comment_for_key(key, last_comment) if last_comment
    end
    
    match = /# *(.*)/.match(line)
    last_comment = match ? match[1] : nil
  end
end
set_translation_for_key(key, lang, value) click to toggle source
# File lib/twine/formatters/flash.rb, line 18
def set_translation_for_key(key, lang, value)
  value = convert_placeholders_from_flash_to_twine(value)
  super(key, lang, value)
end