6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/any2tmx/tmx_writer.rb', line 6
def write(trans_map, options, io)
writer = XmlWriteStream.from_stream(io)
writer.open_tag('tmx', version: '1.4')
writer.open_single_line_tag('header', srclang: options.source[:locale], datatype: 'plaintext', segtype: 'paragraph')
writer.close_tag
writer.open_tag('body')
trans_map.each_pair do |_, target_translations|
writer.open_tag('tu')
target_translations.each do |locale, translation|
writer.open_tag('tuv', 'xml:lang' => locale)
writer.open_single_line_tag('seg')
writer.write_text(translation)
writer.close_tag writer.close_tag end
writer.close_tag end
writer.close
end
|