translatomatic 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. checksums.yaml +5 -5
  2. data/.gitattributes +20 -20
  3. data/.gitignore +19 -15
  4. data/.rspec +3 -3
  5. data/.rubocop.yml +28 -0
  6. data/.translatomatic/config.yml +4 -0
  7. data/.travis.yml +4 -6
  8. data/.yardopts +9 -9
  9. data/Gemfile +8 -4
  10. data/Guardfile +4 -5
  11. data/README.de.md +55 -50
  12. data/README.en.md +177 -0
  13. data/README.es.md +53 -48
  14. data/README.fr.md +53 -48
  15. data/README.it.md +54 -49
  16. data/README.ja.md +63 -58
  17. data/README.ko.md +59 -54
  18. data/README.md +17 -13
  19. data/README.ms.md +50 -45
  20. data/README.pt.md +54 -49
  21. data/README.ru.md +57 -52
  22. data/README.sv.md +51 -46
  23. data/README.zh.md +60 -55
  24. data/Rakefile +3 -3
  25. data/TODO.txt +6 -0
  26. data/bin/console +3 -3
  27. data/bin/translatomatic +4 -2
  28. data/config/i18n-tasks.yml +130 -0
  29. data/config/locales/translatomatic/de.yml +141 -99
  30. data/config/locales/translatomatic/en.yml +129 -89
  31. data/config/locales/translatomatic/es.yml +136 -99
  32. data/config/locales/translatomatic/fr.yml +139 -100
  33. data/config/locales/translatomatic/it.yml +135 -97
  34. data/config/locales/translatomatic/ja.yml +137 -98
  35. data/config/locales/translatomatic/ko.yml +138 -98
  36. data/config/locales/translatomatic/ms.yml +138 -100
  37. data/config/locales/translatomatic/pt.yml +137 -101
  38. data/config/locales/translatomatic/ru.yml +136 -98
  39. data/config/locales/translatomatic/sv.yml +134 -96
  40. data/config/locales/translatomatic/zh.yml +136 -97
  41. data/db/migrate/201712170000_initial.rb +2 -3
  42. data/lib/translatomatic.rb +40 -25
  43. data/lib/translatomatic/cli.rb +5 -1
  44. data/lib/translatomatic/cli/base.rb +61 -58
  45. data/lib/translatomatic/cli/common_options.rb +14 -11
  46. data/lib/translatomatic/cli/config.rb +96 -91
  47. data/lib/translatomatic/cli/database.rb +85 -23
  48. data/lib/translatomatic/cli/main.rb +158 -104
  49. data/lib/translatomatic/cli/thor.rb +29 -0
  50. data/lib/translatomatic/cli/translate.rb +134 -157
  51. data/lib/translatomatic/config.rb +10 -301
  52. data/lib/translatomatic/config/display.rb +78 -0
  53. data/lib/translatomatic/config/files.rb +60 -0
  54. data/lib/translatomatic/config/location_settings.rb +133 -0
  55. data/lib/translatomatic/config/options.rb +68 -0
  56. data/lib/translatomatic/config/selector.rb +127 -0
  57. data/lib/translatomatic/config/settings.rb +148 -0
  58. data/lib/translatomatic/converter.rb +40 -28
  59. data/lib/translatomatic/database.rb +127 -110
  60. data/lib/translatomatic/define_options.rb +4 -5
  61. data/lib/translatomatic/escaped_unicode.rb +86 -76
  62. data/lib/translatomatic/extractor.rb +5 -2
  63. data/lib/translatomatic/extractor/base.rb +12 -12
  64. data/lib/translatomatic/extractor/ruby.rb +7 -6
  65. data/lib/translatomatic/file_translator.rb +101 -244
  66. data/lib/translatomatic/flattenation.rb +39 -0
  67. data/lib/translatomatic/http.rb +13 -0
  68. data/lib/translatomatic/http/client.rb +144 -0
  69. data/lib/translatomatic/http/exception.rb +43 -0
  70. data/lib/translatomatic/http/file_param.rb +27 -0
  71. data/lib/translatomatic/http/param.rb +37 -0
  72. data/lib/translatomatic/http/request.rb +91 -0
  73. data/lib/translatomatic/i18n.rb +43 -0
  74. data/lib/translatomatic/locale.rb +71 -59
  75. data/lib/translatomatic/logger.rb +43 -28
  76. data/lib/translatomatic/metadata.rb +58 -0
  77. data/lib/translatomatic/model.rb +4 -2
  78. data/lib/translatomatic/model/locale.rb +5 -5
  79. data/lib/translatomatic/model/text.rb +5 -5
  80. data/lib/translatomatic/option.rb +57 -34
  81. data/lib/translatomatic/path_utils.rb +126 -0
  82. data/lib/translatomatic/progress_updater.rb +13 -16
  83. data/lib/translatomatic/provider.rb +101 -0
  84. data/lib/translatomatic/provider/base.rb +136 -0
  85. data/lib/translatomatic/provider/frengly.rb +55 -0
  86. data/lib/translatomatic/provider/google.rb +78 -0
  87. data/lib/translatomatic/provider/google_web.rb +50 -0
  88. data/lib/translatomatic/provider/microsoft.rb +144 -0
  89. data/lib/translatomatic/provider/my_memory.rb +75 -0
  90. data/lib/translatomatic/provider/yandex.rb +61 -0
  91. data/lib/translatomatic/resource_file.rb +59 -53
  92. data/lib/translatomatic/resource_file/base.rb +171 -237
  93. data/lib/translatomatic/resource_file/csv.rb +176 -24
  94. data/lib/translatomatic/resource_file/html.rb +21 -42
  95. data/lib/translatomatic/resource_file/key_value_support.rb +117 -0
  96. data/lib/translatomatic/resource_file/markdown.rb +36 -38
  97. data/lib/translatomatic/resource_file/plist.rb +121 -126
  98. data/lib/translatomatic/resource_file/po.rb +104 -82
  99. data/lib/translatomatic/resource_file/properties.rb +48 -77
  100. data/lib/translatomatic/resource_file/properties.treetop +87 -0
  101. data/lib/translatomatic/resource_file/resw.rb +56 -41
  102. data/lib/translatomatic/resource_file/subtitle.rb +86 -54
  103. data/lib/translatomatic/resource_file/text.rb +18 -18
  104. data/lib/translatomatic/resource_file/xcode_strings.rb +32 -63
  105. data/lib/translatomatic/resource_file/xcode_strings.treetop +85 -0
  106. data/lib/translatomatic/resource_file/xml.rb +94 -81
  107. data/lib/translatomatic/resource_file/yaml.rb +54 -68
  108. data/lib/translatomatic/retry_executor.rb +37 -0
  109. data/lib/translatomatic/slurp.rb +32 -0
  110. data/lib/translatomatic/string_batcher.rb +50 -0
  111. data/lib/translatomatic/string_escaping.rb +61 -0
  112. data/lib/translatomatic/text.rb +263 -0
  113. data/lib/translatomatic/text_collection.rb +66 -0
  114. data/lib/translatomatic/tmx.rb +5 -3
  115. data/lib/translatomatic/tmx/document.rb +107 -82
  116. data/lib/translatomatic/tmx/translation_unit.rb +19 -18
  117. data/lib/translatomatic/translation.rb +8 -28
  118. data/lib/translatomatic/translation/collection.rb +199 -0
  119. data/lib/translatomatic/translation/fetcher.rb +123 -0
  120. data/lib/translatomatic/translation/munging.rb +112 -0
  121. data/lib/translatomatic/translation/result.rb +50 -0
  122. data/lib/translatomatic/translation/sharer.rb +32 -0
  123. data/lib/translatomatic/translation/stats.rb +44 -0
  124. data/lib/translatomatic/translator.rb +91 -88
  125. data/lib/translatomatic/type_cast.rb +63 -0
  126. data/lib/translatomatic/util.rb +37 -33
  127. data/lib/translatomatic/version.rb +2 -2
  128. data/translatomatic.gemspec +57 -46
  129. metadata +136 -59
  130. data/lib/translatomatic/http_request.rb +0 -162
  131. data/lib/translatomatic/string.rb +0 -188
  132. data/lib/translatomatic/translation_result.rb +0 -86
  133. data/lib/translatomatic/translation_stats.rb +0 -31
  134. data/lib/translatomatic/translator/base.rb +0 -128
  135. data/lib/translatomatic/translator/frengly.rb +0 -62
  136. data/lib/translatomatic/translator/google.rb +0 -37
  137. data/lib/translatomatic/translator/microsoft.rb +0 -41
  138. data/lib/translatomatic/translator/my_memory.rb +0 -68
  139. data/lib/translatomatic/translator/yandex.rb +0 -56
@@ -1,24 +1,24 @@
1
- module Translatomatic::ResourceFile
2
- # Text resource file
3
- class Text < Base
1
+ module Translatomatic
2
+ module ResourceFile
3
+ # Text resource file
4
+ class Text < Base
5
+ # (see Base.extensions)
6
+ def self.extensions
7
+ %w[txt text]
8
+ end
4
9
 
5
- # (see Translatomatic::ResourceFile::Base.extensions)
6
- def self.extensions
7
- %w{txt text}
8
- end
9
-
10
- # (see Translatomatic::ResourceFile::Base#save)
11
- def save(target = path, options = {})
12
- values = @properties.values.collect { |i| i.strip + "\n" }
13
- target.write(values.join)
14
- end
10
+ # (see Base#save)
11
+ def save(target = path, options = {})
12
+ values = @properties.values.compact.collect { |i| i.strip + "\n" }
13
+ target.write(values.join)
14
+ end
15
15
 
16
- private
16
+ private
17
17
 
18
- def load
19
- text = read_contents(@path)
20
- @properties = { "text" => text }
18
+ def load
19
+ text = read_contents(@path)
20
+ @properties = { 'text' => text }
21
+ end
21
22
  end
22
-
23
23
  end
24
24
  end
@@ -1,75 +1,44 @@
1
- module Translatomatic::ResourceFile
2
-
3
- # @!visibility private
4
- module XCodeStringsLocalePath
5
-
6
- # (see Translatomatic::ResourceFile::Base#locale_path)
7
- # @note localization files in XCode use the following file name
8
- # convention: locale.lproj/filename
9
- def locale_path(locale)
10
- if path.to_s.match(/\b([-\w]+).lproj\/.+$/)
11
- # xcode style
12
- filename = path.basename
13
- path.parent.parent + (locale.to_s + ".lproj") + filename
14
- else
15
- super(locale)
1
+ require 'treetop'
2
+
3
+ module Translatomatic
4
+ module ResourceFile
5
+ # XCode strings resource file
6
+ # @see https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/LoadingResources/Strings/Strings.html
7
+ class XCodeStrings < Base
8
+ include KeyValueSupport
9
+
10
+ # (see Base.extensions)
11
+ def self.extensions
12
+ %w[strings]
16
13
  end
17
- end
18
- end
19
14
 
20
- # XCode strings resource file
21
- # @see https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/LoadingResources/Strings/Strings.html
22
- class XCodeStrings < Base
23
- include Translatomatic::ResourceFile::XCodeStringsLocalePath
15
+ private
24
16
 
25
- # (see Translatomatic::ResourceFile::Base.extensions)
26
- def self.extensions
27
- %w{strings}
28
- end
17
+ Treetop.load(File.join(__dir__, 'xcode_strings.treetop'))
18
+ # @private
19
+ class Parser < XCodeStringsParser; end
29
20
 
30
- # (see Translatomatic::ResourceFile::Base.is_key_value?)
31
- def self.is_key_value?
32
- true
33
- end
34
-
35
- # (see Translatomatic::ResourceFile::Base#save)
36
- def save(target = path, options = {})
37
- out = ""
38
- out += comment(created_by) unless options[:no_created_by]
39
- properties.each do |key, value|
40
- key = escape(key)
41
- value = escape(value)
42
- out += %Q{"#{key}" = "#{value}";\n}
21
+ def parse_doc(content)
22
+ Parser.new.parse(content)
43
23
  end
44
- target.write(out)
45
- end
46
-
47
- private
48
24
 
49
- def load
50
- result = {}
51
- content = read_contents(@path)
52
- uncommented = content.gsub(/\/\*.*?\*\//, '')
53
- key_values = uncommented.scan(/"(.*?[^\\])"\s*=\s*"(.*?[^\\])"\s*;/m)
54
- key_values.each do |entry|
55
- key, value = entry
56
- result[unescape(key)] = unescape(value)
25
+ def definition_to_s(key, value)
26
+ format(%("%<key>s" = "%<value>s";\n\n), key: escape(key),
27
+ value: escape(value))
57
28
  end
58
29
 
59
- @properties = result
60
- end
61
-
62
- def comment(text)
63
- "/* #{text} */\n"
64
- end
65
-
66
- def unescape(string)
67
- string ? string.gsub(/\\(["'])/) { |i| i } : ''
68
- end
30
+ def comment_to_s(text)
31
+ comment = text && text.start_with?(' ') ? text : " #{text} "
32
+ "/*#{comment}*/\n"
33
+ end
69
34
 
70
- def escape(string)
71
- string ? string.gsub(/["']/) { |i| "\\#{i}" } : ''
35
+ def render_element(element)
36
+ if element.is_a? Comment
37
+ comment_to_s(element.text)
38
+ elsif element.is_a? Definition
39
+ definition_to_s(element.key, element.value)
40
+ end
41
+ end
72
42
  end
73
-
74
43
  end
75
44
  end
@@ -0,0 +1,85 @@
1
+ grammar XCodeStrings
2
+ rule document
3
+ (whitespace / comment / definition)* {
4
+ def content
5
+ elements.collect { |i| i.content }.select { |i| i[0] != :whitespace }
6
+ end
7
+ }
8
+ end
9
+
10
+ rule comment
11
+ start_comment comment_content end_comment {
12
+ def content
13
+ [:comment, elements[1].text_value]
14
+ end
15
+ }
16
+ end
17
+
18
+ rule comment_content
19
+ (!end_comment character)+
20
+ end
21
+
22
+ rule definition
23
+ key assignment value end_definition {
24
+ def content
25
+ [:definition, elements[0].content, elements[2].content]
26
+ end
27
+ }
28
+ end
29
+
30
+ rule end_definition
31
+ whitespace* ';'
32
+ end
33
+
34
+ rule assignment
35
+ whitespace* '=' whitespace*
36
+ end
37
+
38
+ rule key
39
+ quoted_string
40
+ end
41
+
42
+ rule value
43
+ quoted_string
44
+ end
45
+
46
+ rule whitespace
47
+ [ \t\r\n] {
48
+ def content
49
+ [:whitespace, text_value]
50
+ end
51
+ }
52
+ end
53
+
54
+ rule start_comment
55
+ '/*'
56
+ end
57
+
58
+ rule end_comment
59
+ '*/'
60
+ end
61
+
62
+ rule character
63
+ .
64
+ end
65
+
66
+ rule string_content
67
+ (escaped_double_quote / !double_quote character)*
68
+ end
69
+
70
+ rule escaped_double_quote
71
+ '\\' double_quote
72
+ end
73
+
74
+ rule double_quote
75
+ '"'
76
+ end
77
+
78
+ rule quoted_string
79
+ double_quote string_content double_quote {
80
+ def content
81
+ elements[1].text_value
82
+ end
83
+ }
84
+ end
85
+ end
@@ -1,103 +1,116 @@
1
- module Translatomatic::ResourceFile
2
- # XML resource file
3
- class XML < Base
4
-
5
- # (see Translatomatic::ResourceFile::Base.extensions)
6
- def self.extensions
7
- %w{xml}
8
- end
1
+ module Translatomatic
2
+ module ResourceFile
3
+ # XML resource file
4
+ class XML < Base
5
+ # (see Base.extensions)
6
+ def self.extensions
7
+ %w[xml]
8
+ end
9
9
 
10
- # (see Translatomatic::ResourceFile::Base#set)
11
- def set(key, value)
12
- super(key, value)
13
- if @nodemap.include?(key)
14
- @nodemap[key].content = value
15
- else
16
- create_node(key, value)
10
+ # (see Base#set)
11
+ def set(key, value)
12
+ super(key, value)
13
+ if @nodemap.include?(key)
14
+ @nodemap[key].content = value
15
+ else
16
+ create_node(key, value)
17
+ end
17
18
  end
18
- end
19
19
 
20
- # (see Translatomatic::ResourceFile::Base#save)
21
- def save(target = path, options = {})
22
- if @doc
23
- add_created_by unless options[:no_created_by]
20
+ # (see Base#save)
21
+ def save(target = path, options = {})
22
+ return unless @doc
23
+ add_created_by unless options[:no_created_by] || created_by?
24
24
  target.write(@doc.to_xml(indent: 2))
25
25
  end
26
- end
27
26
 
28
- private
27
+ private
29
28
 
30
- def init
31
- @nodemap = {}
32
- @doc = empty_doc
33
- end
29
+ TM_NS = 'http://www.smugglys.com/2018/translatomatic'.freeze
34
30
 
35
- def load
36
- # parse xml with nokogiri
37
- @doc = read_doc
38
- init_nodemap
39
- init_properties
40
- end
31
+ def init
32
+ @nodemap = {}
33
+ @doc = empty_doc
34
+ end
41
35
 
42
- def comment(text)
43
- @doc.create_comment(text)
44
- end
36
+ def load
37
+ # parse xml with nokogiri
38
+ @metadata.reset
39
+ @doc = read_doc
40
+ init_nodemap
41
+ init_properties
42
+ end
45
43
 
46
- def add_created_by
47
- @created_by ||= @doc.root.add_previous_sibling(comment(created_by))
48
- end
44
+ def comment(text)
45
+ @doc.create_comment(text)
46
+ end
49
47
 
50
- def init_properties
51
- @properties = @nodemap.transform_values { |i| i ? i.content : nil }
52
- end
48
+ def add_created_by
49
+ @created_by ||= @doc.root.add_previous_sibling(comment(created_by))
50
+ end
53
51
 
54
- # initialize nodemap and properties hash from nokogiri document
55
- def init_nodemap
56
- # map of key1 => node, key2 => node, ...
57
- @keynum = 1
58
- text_nodes = @doc.search(text_nodes_xpath)
59
- text_nodes.each { |node| add_node(node) }
60
- end
52
+ def init_properties
53
+ @properties = @nodemap.transform_values { |i| i ? i.content : nil }
54
+ end
61
55
 
62
- def read_doc
63
- doc = Nokogiri::XML(@path.open) do |config|
64
- config.noblanks
56
+ # initialize nodemap and properties hash from nokogiri document
57
+ def init_nodemap
58
+ # map of key1 => node, key2 => node, ...
59
+ @keynum = 1
60
+ text_nodes = @doc.search(text_nodes_xpath, tm: TM_NS)
61
+ text_nodes.each { |node| add_node(node) }
65
62
  end
66
- parsing_error(doc.errors[0]) if doc.errors.present?
67
- doc
68
- end
69
63
 
70
- def create_node(key, value)
71
- # separate nodes by whitespace
72
- text_node = Nokogiri::XML::Text.new("\n", @doc)
73
- @doc.root.add_child(text_node)
64
+ def read_doc
65
+ doc = Nokogiri::XML(@path.open, &:noblanks)
66
+ parsing_error(doc.errors[0]) if doc.errors.present?
67
+ doc
68
+ end
74
69
 
75
- # create the key/value node
76
- node = Nokogiri::XML::Node.new(key, @doc)
77
- node.content = value
78
- @doc.root.add_child(node)
70
+ def create_node(key, value)
71
+ # separate nodes by whitespace
72
+ text_node = Nokogiri::XML::Text.new("\n", @doc)
73
+ @doc.root.add_child(text_node)
79
74
 
80
- @nodemap[key] = node
81
- @properties[key] = node.content
82
- end
75
+ # create the key/value node
76
+ node = Nokogiri::XML::Node.new(key, @doc)
77
+ node.content = value
78
+ @doc.root.add_child(node)
83
79
 
84
- def add_node(node)
85
- return if whitespace?(node.content)
86
- key = "key#{@keynum}"
87
- @nodemap[key] = node
88
- @keynum += 1
89
- end
80
+ @nodemap[key] = node
81
+ @properties[key] = node.content
82
+ end
90
83
 
91
- def empty_doc
92
- Nokogiri::XML("<root />")
93
- end
84
+ def add_node(node)
85
+ return if whitespace?(node.content)
86
+ if node.comment?
87
+ @metadata.parse_comment(node.content)
88
+ elsif context_attribute?(node)
89
+ @metadata.add_context(node.content)
90
+ else
91
+ key = "key#{@keynum}"
92
+ @nodemap[key] = node
93
+ @keynum += 1
94
+ @metadata.assign_key(key)
95
+ end
96
+ end
94
97
 
95
- def text_nodes_xpath
96
- '//text()'
97
- end
98
+ def context_attribute?(node)
99
+ node.name == 'context' && node.namespace &&
100
+ node.namespace.href == TM_NS
101
+ end
102
+
103
+ def empty_doc
104
+ Nokogiri::XML('<root />')
105
+ end
98
106
 
99
- def whitespace?(text)
100
- text == nil || text.strip.length == 0
107
+ def text_nodes_xpath
108
+ '//text()|//comment()|//@tm:context'
109
+ end
110
+
111
+ def whitespace?(text)
112
+ text.nil? || text.strip.empty?
113
+ end
101
114
  end
102
- end # class
103
- end # module
115
+ end
116
+ end
@@ -1,52 +1,39 @@
1
1
  require 'yaml'
2
2
 
3
- module Translatomatic::ResourceFile
4
- # YAML resource file
5
- # @see http://www.yaml.org/
6
- class YAML < Base
7
-
8
- # (see Translatomatic::ResourceFile::Base.extensions)
9
- def self.extensions
10
- %w{yml yaml}
11
- end
12
-
13
- # (see Translatomatic::ResourceFile::Base.is_key_value?)
14
- def self.is_key_value?
15
- true
16
- end
3
+ module Translatomatic
4
+ module ResourceFile
5
+ # YAML resource file
6
+ # @see http://www.yaml.org/
7
+ class YAML < Base
8
+ # (see Base.extensions)
9
+ def self.extensions
10
+ %w[yml yaml]
11
+ end
17
12
 
18
- # (see Translatomatic::ResourceFile::Base.supports_variable_interpolation?)
19
- def self.supports_variable_interpolation?
20
- true
21
- end
13
+ # (see Base.key_value?)
14
+ def self.key_value?
15
+ true
16
+ end
22
17
 
23
- # (see Translatomatic::ResourceFile::Base#locale_path)
24
- # @note localization files in rails use the following file name
25
- # convention: config/locales/en.yml.
26
- def locale_path(locale)
27
- if path.to_s.match(/config\/locales\/[-\w]+.yml$/)
28
- # rails style
29
- filename = locale.to_s + path.extname
30
- path.dirname + filename
31
- else
32
- super(locale)
18
+ # (see Base.supports_variable_interpolation?)
19
+ def self.supports_variable_interpolation?
20
+ true
33
21
  end
34
- end
35
22
 
36
- # (see Translatomatic::ResourceFile::Base#set)
37
- def set(key, value)
38
- super(key, value)
23
+ # (see Base#set)
24
+ def set(key, value)
25
+ super(key, value)
39
26
 
40
- hash = @data
41
- path = key.to_s.split(/\./)
42
- last_key = path.pop
43
- path.each { |i| hash = (hash[i] ||= {}) }
44
- hash[last_key] = value
45
- end
27
+ hash = @data
28
+ path = key.to_s.split(/\./)
29
+ last_key = path.pop
30
+ path.each { |i| hash = (hash[i] ||= {}) }
31
+ hash[last_key] = value
32
+ end
46
33
 
47
- # (see Translatomatic::ResourceFile::Base#save)
48
- def save(target = path, options = {})
49
- if @data
34
+ # (see Base#save)
35
+ def save(target = path, options = {})
36
+ return unless @data
50
37
  data = @data
51
38
  data = data.transform_keys { locale.language } if ruby_i18n?
52
39
  out = data.to_yaml
@@ -54,41 +41,40 @@ module Translatomatic::ResourceFile
54
41
  out = comment(created_by) + "\n" + out unless options[:no_created_by]
55
42
  target.write(out)
56
43
  end
57
- end
58
44
 
59
- # (see Translatomatic::ResourceFile::Base#create_variable)
60
- def create_variable(name)
61
- return "%{#{name}}"
62
- end
45
+ # (see Base#create_variable)
46
+ def create_variable(name)
47
+ "%{#{name}}"
48
+ end
63
49
 
64
- # (see Translatomatic::ResourceFile::Base#variable_regex)
65
- def variable_regex
66
- /\%\s*\{.*?\}/
67
- end
50
+ # (see Base#variable_regex)
51
+ def variable_regex
52
+ /\%\s*\{.*?\}/
53
+ end
68
54
 
69
- private
55
+ private
70
56
 
71
- def init
72
- # yaml data
73
- @data = {}
74
- end
57
+ def init
58
+ # yaml data
59
+ @data = {}
60
+ end
75
61
 
76
- def load
77
- @data = ::YAML.load_file(path.to_s) || {}
78
- @properties = flatten(@data)
79
- end
62
+ def load
63
+ @data = ::YAML.load_file(path.to_s) || {}
64
+ @properties = flatten(@data)
65
+ end
80
66
 
81
- # true if this resource file looks like a ruby i18n data file.
82
- def ruby_i18n?
83
- if @data && @data.length == 1
84
- lang = @data.keys[0]
85
- Translatomatic::Locale.new(lang).valid?
67
+ # true if this resource file looks like a ruby i18n data file.
68
+ def ruby_i18n?
69
+ if @data && @data.length == 1
70
+ lang = @data.keys[0]
71
+ Translatomatic::Locale.new(lang).valid?
72
+ end
86
73
  end
87
- end
88
74
 
89
- def comment(text)
90
- "# #{text}\n"
75
+ def comment(text)
76
+ "# #{text}\n"
77
+ end
91
78
  end
92
-
93
79
  end
94
80
  end