xliffle 0.0.6 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d3397cd5843dd6cc40a1c3e6a9c53ea005663bcf
4
- data.tar.gz: 5b3e7b6168395676b01061c9e9029137af4ac6a4
3
+ metadata.gz: 9c3e2597e48807a7fa1d71cf71b958a1bc19433b
4
+ data.tar.gz: e3a70fd86c7d88559f2ce47d2456e67a57a887c4
5
5
  SHA512:
6
- metadata.gz: 9c0333d741b07d1dec42b57ac2ffc5f7226a441c728fc67139d5b6769e5a4cfce41f7214edf94c28a0d98bc22328d0b589f1fccc0928ba698d82a931685115d5
7
- data.tar.gz: 13b2892268a84b177338c130c46a6e822f362234c08cac0647c5fdc50498e5b84a8be7d2d1b91e1cd48c9b93a0f569ca9b0598758bbf24cdb6c2b9d12a248a1f
6
+ metadata.gz: c1ebe0e776e9e865411fd0b66d271ce9dda1402e8998cca6a6566ce038e4736721c4be92db3c73dffdc3117120c029572c642164edb19fa11482b572ef339e63
7
+ data.tar.gz: ad378bba4a0ac3a5e6f9b0b21c2b79b4a4e52cfdf6173595f36f4841ff9f7b9090c610594678c359df35899a22fbb7d8f355dd33d06b5a67e358ab4525f9fecf
data/lib/xliffle.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'xliffle/creator'
2
2
  require 'xliffle/file'
3
3
  require 'xliffle/string'
4
+ require 'xliffle/note'
4
5
 
5
6
  module Xliffle
6
7
  def self.new
data/lib/xliffle/file.rb CHANGED
@@ -17,10 +17,10 @@ module Xliffle
17
17
  end
18
18
 
19
19
  def to_xliff(xliff)
20
- xliff.file(original: @original, datatype: 'plaintext', 'source-language' => @source_locale, 'target-language' => @target_locale,) do |f|
21
- f.body do |b|
20
+ xliff.file(original: @original, datatype: 'plaintext', 'source-language' => @source_locale, 'target-language' => @target_locale,) do |file|
21
+ file.body do |body|
22
22
  self.strings.each do |string|
23
- string.to_xliff(b)
23
+ string.to_xliff(body)
24
24
  end
25
25
  end
26
26
  end
@@ -0,0 +1,14 @@
1
+ module Xliffle
2
+ class Note
3
+ attr_reader :note, :priority
4
+
5
+ def initialize(note, options={})
6
+ @note = note
7
+ @priority = options[:priority] || 2
8
+ end
9
+
10
+ def to_xliff(xliff)
11
+ xliff.tag!('note', { priority: @priority }, @note)
12
+ end
13
+ end
14
+ end
@@ -1,18 +1,28 @@
1
1
  module Xliffle
2
2
  class String
3
- attr_reader :name, :source, :target
3
+ attr_reader :name, :source, :target, :notes
4
4
 
5
- def initialize(id, name, source, target)
5
+ def initialize(id, name, source_string, target_string)
6
6
  @id = id
7
7
  @name = name
8
- @source = source
9
- @target = target
8
+ @source_string = source_string
9
+ @target_string = target_string
10
+ @notes = []
11
+ end
12
+
13
+ def note(note, priority=2)
14
+ note = Xliffle::Note.new(note, priority)
15
+ @notes << note
16
+ note
10
17
  end
11
18
 
12
19
  def to_xliff(xliff)
13
- xliff.tag!('trans-unit', { id: @id, resname: @name }) do |t|
14
- t.source(@source)
15
- t.target(@target)
20
+ xliff.tag!('trans-unit', { id: @id, resname: @name }) do |tag|
21
+ tag.source(@source_string)
22
+ tag.target(@target_string)
23
+ @notes.each do |note|
24
+ note.to_xliff(tag)
25
+ end
16
26
  end
17
27
  end
18
28
  end
@@ -1,3 +1,3 @@
1
1
  module Xliffle
2
- VERSION = "0.0.6"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xliffle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Rohde
@@ -64,6 +64,7 @@ files:
64
64
  - lib/xliffle.rb
65
65
  - lib/xliffle/creator.rb
66
66
  - lib/xliffle/file.rb
67
+ - lib/xliffle/note.rb
67
68
  - lib/xliffle/string.rb
68
69
  - lib/xliffle/version.rb
69
70
  - test/test_helper.rb