Class: Twine::Formatters::Flash
Instance Attribute Summary
Attributes inherited from Abstract
#options, #strings
Instance Method Summary
collapse
Methods inherited from Abstract
#escape_quotes, #format_file, #format_key, #format_key_value, #format_row, #format_section, #initialize, #output_path_for_language, #set_comment_for_key, #set_translation_for_key, #should_include_row
Instance Method Details
#can_handle_directory?(path) ⇒ Boolean
12
13
14
|
# File 'lib/twine/formatters/flash.rb', line 12
def can_handle_directory?(path)
return false
end
|
#default_file_name ⇒ Object
16
17
18
|
# File 'lib/twine/formatters/flash.rb', line 16
def default_file_name
return 'resources.properties'
end
|
#determine_language_given_path(path) ⇒ Object
20
21
22
|
# File 'lib/twine/formatters/flash.rb', line 20
def determine_language_given_path(path)
return
end
|
#extension ⇒ Object
8
9
10
|
# File 'lib/twine/formatters/flash.rb', line 8
def extension
'.properties'
end
|
59
60
61
|
# File 'lib/twine/formatters/flash.rb', line 59
def (row, lang)
"# #{row.comment}\n" if row.
end
|
51
52
53
|
# File 'lib/twine/formatters/flash.rb', line 51
def (lang)
"## Flash Strings File\n## Generated by Twine #{Twine::VERSION}\n## Language: #{lang}"
end
|
4
5
6
|
# File 'lib/twine/formatters/flash.rb', line 4
def format_name
'flash'
end
|
55
56
57
|
# File 'lib/twine/formatters/flash.rb', line 55
def (section)
"## #{section.name} ##\n"
end
|
47
48
49
|
# File 'lib/twine/formatters/flash.rb', line 47
def format_sections(strings, lang)
super + "\n"
end
|
67
68
69
70
|
# File 'lib/twine/formatters/flash.rb', line 67
def format_value(value)
placeHolderNumber = -1
value.gsub(/%[d@]/) { placeHolderNumber += 1; '{%d}' % placeHolderNumber }
end
|
#key_value_pattern ⇒ Object
63
64
65
|
# File 'lib/twine/formatters/flash.rb', line 63
def key_value_pattern
"%{key}=%{value}"
end
|
#read(io, lang) ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/twine/formatters/flash.rb', line 24
def read(io, lang)
= nil
while line = io.gets
match = /((?:[^"\\]|\\.)+)\s*=\s*((?:[^"\\]|\\.)*)/.match(line)
if match
key = match[1]
value = match[2].strip
value.gsub!(/\{[0-9]\}/, '%@')
set_translation_for_key(key, lang, value)
if
(key, )
end
end
match = /# *(.*)/.match(line)
if match
= match[1]
else
= nil
end
end
end
|