Class: Twine::Formatters::Flash
Constant Summary
Placeholders::PLACEHOLDER_FLAGS_WIDTH_PRECISION_LENGTH, Placeholders::PLACEHOLDER_PARAMETER_FLAGS_WIDTH_PRECISION_LENGTH, Placeholders::PLACEHOLDER_REGEX, Placeholders::PLACEHOLDER_TYPES
Constants inherited
from Abstract
Abstract::LANGUAGE_CODE_WITH_OPTIONAL_REGION_CODE
Instance Attribute Summary
Attributes inherited from Abstract
#options, #twine_file
Instance Method Summary
collapse
#contains_python_specific_placeholder, #convert_placeholders_from_android_to_twine, #convert_placeholders_from_flash_to_twine, #convert_placeholders_from_twine_to_android, #convert_placeholders_from_twine_to_flash, #convert_twine_string_placeholder, #number_of_twine_placeholders
Methods inherited from Abstract
#can_handle_directory?, #determine_language_given_path, #escape_quotes, #format_definition, #format_file, #format_key, #format_key_value, #format_section, #initialize, #output_path_for_language, #set_comment_for_key, #should_include_definition
Instance Method Details
#default_file_name ⇒ Object
14
15
16
|
# File 'lib/twine/formatters/flash.rb', line 14
def default_file_name
'resources.properties'
end
|
#extension ⇒ Object
10
11
12
|
# File 'lib/twine/formatters/flash.rb', line 10
def extension
'.properties'
end
|
52
53
54
|
# File 'lib/twine/formatters/flash.rb', line 52
def (definition, lang)
"# #{definition.}\n" if definition.
end
|
44
45
46
|
# File 'lib/twine/formatters/flash.rb', line 44
def (lang)
"## Flash Strings File\n## Generated by Twine #{Twine::VERSION}\n## Language: #{lang}"
end
|
6
7
8
|
# File 'lib/twine/formatters/flash.rb', line 6
def format_name
'flash'
end
|
48
49
50
|
# File 'lib/twine/formatters/flash.rb', line 48
def (section)
"## #{section.name} ##\n"
end
|
40
41
42
|
# File 'lib/twine/formatters/flash.rb', line 40
def format_sections(twine_file, lang)
super + "\n"
end
|
60
61
62
|
# File 'lib/twine/formatters/flash.rb', line 60
def format_value(value)
convert_placeholders_from_twine_to_flash(value)
end
|
#key_value_pattern ⇒ Object
56
57
58
|
# File 'lib/twine/formatters/flash.rb', line 56
def key_value_pattern
"%{key}=%{value}"
end
|
#read(io, lang) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/twine/formatters/flash.rb', line 23
def read(io, lang)
= 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)
(key, ) if
end
match = /# *(.*)/.match(line)
= match ? match[1] : nil
end
end
|
#set_translation_for_key(key, lang, value) ⇒ Object
18
19
20
21
|
# 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
|