class Translatomatic::ResourceFile::Properties

Properties resource file @see docs.oracle.com/javase/tutorial/essential/environment/properties.html

Public Class Methods

extensions() click to toggle source

(see Base.extensions)

# File lib/translatomatic/resource_file/properties.rb, line 11
def self.extensions
  %w[properties]
end
preferred_locale_separator() click to toggle source

(see Base.preferred_locale_separator)

# File lib/translatomatic/resource_file/properties.rb, line 21
def self.preferred_locale_separator
  '_'
end
supports_variable_interpolation?() click to toggle source

(see Base.supports_variable_interpolation?)

# File lib/translatomatic/resource_file/properties.rb, line 16
def self.supports_variable_interpolation?
  true
end

Public Instance Methods

create_variable(name) click to toggle source

(see Base#create_variable)

# File lib/translatomatic/resource_file/properties.rb, line 26
def create_variable(name)
  "{#{name}}"
end
variable_regex() click to toggle source

(see Base#variable_regex)

# File lib/translatomatic/resource_file/properties.rb, line 31
def variable_regex
  /\{.*?\}/
end

Private Instance Methods

parse_doc(content) click to toggle source
# File lib/translatomatic/resource_file/properties.rb, line 41
def parse_doc(content)
  Parser.new.parse(content)
end
render_element(element) click to toggle source
# File lib/translatomatic/resource_file/properties.rb, line 45
def render_element(element)
  if element.is_a? Comment
    return '' if element.text.nil?
    comments = element.text.split(/[\r\n]+/)
    comments.collect do |comment|
      format("%<type>c %<comment>s\n",
             type: element.type, comment: comment.strip)
    end.join
  elsif element.is_a? Definition
    key = element.key
    value = element.value
    format(%(%<key>s = %<value>s\n),
           key: escape(key), value: escape(value))
  end
end