tmx_importer 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3257bc81284bce15ebf42b0e8505f25314473bcc
4
- data.tar.gz: 930e6d4e5e16d72f6c46d6d29a0170a37049c460
3
+ metadata.gz: 7424c506cc51203870a3071cf7a09a90e2aa1af9
4
+ data.tar.gz: ff7ae48224eb2f8a03bc8d550f23735ea76f003a
5
5
  SHA512:
6
- metadata.gz: 4d3b0951312776fb1046bbbf8fb029b7d4829b9bcac0d4904909eb286d26327de136afa9c623692f0a6468e774628ede5bdd12d1399c1f4139d0a164830dfd18
7
- data.tar.gz: 521f1f035a34c5e0c0785901c08b5720b0729ba85104bbedc6ec57676981070ed971935a4b832a8105138de628473fb8f76f0c32895f1c0c2ae13ca6d3a52afe
6
+ metadata.gz: 512fb82572a62c8bc7b27fd1ff82ae8152e7bca9581b0e968c2bcdc1b4f4e2b5a89bcc4562241bc5e8fd22daf7ca33213b205f572319f7f416cf63f22b9e41d2
7
+ data.tar.gz: cc89619e0ee8c0b0ed2c799573c5d64fa8e8fcae9d4e47328b5f0719dedffe6668beadf50006a4f4764b187c462c64dee9888ab0914f174c6e574174295f179a
@@ -1,3 +1,3 @@
1
1
  module TmxImporter
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
3
3
  end
data/lib/tmx_importer.rb CHANGED
@@ -65,11 +65,13 @@ module TmxImporter
65
65
  end
66
66
 
67
67
  def analyze_line(line)
68
- @doc[:source_language] = line.scan(/(?<=srclang=\S)\S+(?=")|(?=')/)[0] if line.include?('srclang=')
68
+ @doc[:source_language] = line.scan(/(?<=srclang=\S)\S+(?=")/)[0] if line.include?('srclang=') && !line.scan(/(?<=srclang=\S)\S+(?=")/).empty?
69
+ @doc[:source_language] = line.scan(/(?<=srclang=\S)\S+(?=')/)[0] if line.include?('srclang=') && !line.scan(/(?<=srclang=\S)\S+(?=')/).empty?
69
70
  @doc[:tu][:counter] += line.scan(/<\/tu>/).count
70
71
  @doc[:seg][:counter] += line.scan(/<\/seg>/).count
71
72
  if line.include?('lang')
72
- @doc[:seg][:lang] = line.scan(/(?<=[^cn]lang=\S)\S+(?=")|(?=')/)[0]
73
+ @doc[:seg][:lang] = line.scan(/(?<=[^cn]lang=\S)\S+(?=")/)[0] if !line.scan(/(?<=[^cn]lang=\S)\S+(?=")/).empty?
74
+ @doc[:seg][:lang] = line.scan(/(?<=[^cn]lang=\S)\S+(?=')/)[0] if !line.scan(/(?<=[^cn]lang=\S)\S+(?=')/).empty?
73
75
  @doc[:seg][:lang] = @doc[:seg][:lang] unless @doc[:seg][:lang].nil?
74
76
  write_language_pair
75
77
  end
@@ -0,0 +1,38 @@
1
+ <?xml version='1.0' encoding='utf-8'?>
2
+ <tmx version='1.4'>
3
+ <header creationtool='AwesomeTool' creationtoolversion='2.0' datatype='plaintext' segtype='sentence' o-tmf='AwesomeTool TMX' adminlang='EN-US' srclang='de-DE'></header>
4
+ <body>
5
+ <tu tuid='1'>
6
+ <tuv xml:lang='de-DE'>
7
+ <seg>überprüfen</seg>
8
+ </tuv>
9
+ <tuv xml:lang='en-US'>
10
+ <seg>check</seg>
11
+ </tuv>
12
+ </tu>
13
+ <tu tuid='2'>
14
+ <tuv xml:lang='de-DE'>
15
+ <seg>Rückenlehneneinstellung</seg>
16
+ </tuv>
17
+ <tuv xml:lang='en-US'>
18
+ <seg>Backrest adjustment</seg>
19
+ </tuv>
20
+ </tu>
21
+ <tu tuid='3'>
22
+ <tuv xml:lang='de-DE'>
23
+ <seg>Bezüglich</seg>
24
+ </tuv>
25
+ <tuv xml:lang='en-US'>
26
+ <seg>In terms of</seg>
27
+ </tuv>
28
+ </tu>
29
+ <tu tuid='4'>
30
+ <tuv xml:lang='de-DE'>
31
+ <seg>Der Staatsschutz prüft, ob es einen Zusammenhang mit einem Anschlag auf eine geplante Flüchtlingsunterkunft in der Nachbarschaft Ende August gibt.</seg>
32
+ </tuv>
33
+ <tuv xml:lang='en-US'>
34
+ <seg>The state protection checks whether there is a connection with an attack on a planned refugee camp in the neighborhood of late August.</seg>
35
+ </tuv>
36
+ </tu>
37
+ </body>
38
+ </tmx>
@@ -74,6 +74,12 @@ describe TmxImporter do
74
74
  tmx = TmxImporter::Tmx.new(file_path: file_path)
75
75
  expect(tmx.stats).to eq({:tu_count=>1, :seg_count=>2, :language_pairs=>[["tr", "en"]]})
76
76
  end
77
+
78
+ it 'imports a TMX file with single quotes' do
79
+ file_path = File.expand_path('../tmx_importer/spec/test_sample_files/single_quotes.tmx')
80
+ tmx = TmxImporter::Tmx.new(file_path: file_path)
81
+ expect(tmx.stats).to eq({:tu_count=>4, :seg_count=>8, :language_pairs=>[["de-DE", "en-US"]]})
82
+ end
77
83
  end
78
84
 
79
85
  describe '#import' do
@@ -130,5 +136,11 @@ describe TmxImporter do
130
136
  tmx = TmxImporter::Tmx.new(file_path: file_path)
131
137
  expect(tmx.import[1][1][3]).to eq("en")
132
138
  end
139
+
140
+ it 'imports a TMX file with single_quotes' do
141
+ file_path = File.expand_path('../tmx_importer/spec/test_sample_files/single_quotes.tmx')
142
+ tmx = TmxImporter::Tmx.new(file_path: file_path)
143
+ expect(tmx.import[1][2][3]).to eq("de-DE")
144
+ end
133
145
  end
134
146
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tmx_importer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin S. Dias
@@ -116,6 +116,7 @@ files:
116
116
  - spec/test_sample_files/bad_markup(utf-8).tmx
117
117
  - spec/test_sample_files/multiple_language_pairs.tmx
118
118
  - spec/test_sample_files/out_of_order_segments.tmx
119
+ - spec/test_sample_files/single_quotes.tmx
119
120
  - spec/test_sample_files/srclang_all.tmx
120
121
  - spec/test_sample_files/strange_encoding.tmx
121
122
  - spec/test_sample_files/test_tm(utf-16LE BOM).tmx
@@ -154,6 +155,7 @@ test_files:
154
155
  - spec/test_sample_files/bad_markup(utf-8).tmx
155
156
  - spec/test_sample_files/multiple_language_pairs.tmx
156
157
  - spec/test_sample_files/out_of_order_segments.tmx
158
+ - spec/test_sample_files/single_quotes.tmx
157
159
  - spec/test_sample_files/srclang_all.tmx
158
160
  - spec/test_sample_files/strange_encoding.tmx
159
161
  - spec/test_sample_files/test_tm(utf-16LE BOM).tmx