gettext 3.0.2 → 3.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -23,36 +23,83 @@ require 'gettext/tools/msgmerge'
23
23
  class TestToolsMsgMerge < Test::Unit::TestCase
24
24
  class TestMerger < self
25
25
  def setup
26
- @merger = GetText::Tools::MsgMerge::Merger.new
27
26
  @po = GetText::PO.new
28
27
  @pot = GetText::PO.new
28
+ @config = GetText::Tools::MsgMerge::Config.new
29
29
  end
30
30
 
31
- def test_add_entry
32
- @po["hello"] = "bonjour"
33
- @pot["hello"] = "bonjour"
34
- @pot["he"] = "il"
35
- merged_po = @merger.merge(@po, @pot)
31
+ def parse_po(po, output)
32
+ parser = GetText::POParser.new
33
+ parser.report_warning = false
34
+ parser.parse(po, output)
35
+ end
36
36
 
37
- assert_equal("bonjour", merged_po["hello"].msgstr)
38
- assert_equal("il", merged_po["he"].msgstr)
37
+ def merge
38
+ merger = GetText::Tools::MsgMerge::Merger.new(@pot, @po, @config)
39
+ merger.merge
39
40
  end
40
41
 
41
- def test_existing_obsolete_entry
42
- @po["hello"] = "bonjour"
43
- @po[:last] = generate_entry(:msgid => :last,
44
- :comment => "#~ obsolete_entry")
45
- @pot["hello"] = "bonjour"
46
- merged_po = @merger.merge(@po, @pot)
42
+ class TestUpdate < self
43
+ def test_msgstr
44
+ pot = <<-POT
45
+ msgid "hello"
46
+ msgstr ""
47
+ POT
48
+ po = <<-PO
49
+ msgid "hello"
50
+ msgstr "bonjour"
51
+ PO
52
+ merged_po = merge(pot, po)
47
53
 
48
- assert_equal("bonjour", merged_po["hello"].msgstr)
49
- assert_nil(merged_po[:last])
54
+ assert_equal(<<-PO, merged_po)
55
+ msgid "hello"
56
+ msgstr "bonjour"
57
+ PO
58
+ end
59
+
60
+ private
61
+ def merge(pot, po)
62
+ parse_po(pot, @pot)
63
+ parse_po(po, @po)
64
+ super().to_s
65
+ end
66
+ end
67
+
68
+ class TestObosleteEntry < self
69
+ def test_in_po
70
+ pot = <<-POT
71
+ msgid "hello"
72
+ msgstr ""
73
+ POT
74
+ po = <<-PO
75
+ msgid "hello"
76
+ msgstr "bonjour"
77
+
78
+ #~ msgid "he"
79
+ #~ msgstr "il"
80
+ PO
81
+
82
+ assert_equal(<<-PO, merge(pot, po))
83
+ msgid "hello"
84
+ msgstr "bonjour"
85
+
86
+ #~ msgid "he"
87
+ #~ msgstr "il"
88
+ PO
89
+ end
90
+
91
+ private
92
+ def merge(pot, po)
93
+ parse_po(pot, @pot)
94
+ parse_po(po, @po)
95
+ super().to_s
96
+ end
50
97
  end
51
98
 
52
99
  def test_different_msgstr
53
100
  @po["hello"] = "salut"
54
101
  @pot["hello"] = "bonjour"
55
- merged_po = @merger.merge(@po, @pot)
102
+ merged_po = merge
56
103
 
57
104
  assert_equal("salut", merged_po["hello"].msgstr)
58
105
  end
@@ -66,7 +113,7 @@ class TestToolsMsgMerge < Test::Unit::TestCase
66
113
  :msgstr => "",
67
114
  :translator_comment => "It's comments")
68
115
 
69
- merged_po = @merger.merge(@po, @pot)
116
+ merged_po = merge
70
117
  assert_equal("bonjour", merged_po["hello"].msgstr)
71
118
  assert_equal("comment", merged_po["hello"].translator_comment)
72
119
  end
@@ -80,7 +127,7 @@ class TestToolsMsgMerge < Test::Unit::TestCase
80
127
  :msgstr => "",
81
128
  :extracted_comment => "extracted comments")
82
129
 
83
- merged_po = @merger.merge(@po, @pot)
130
+ merged_po = merge
84
131
  assert_equal("bonjour", merged_po["hello"].msgstr)
85
132
  assert_equal("extracted comments", merged_po["hello"].extracted_comment)
86
133
  end
@@ -96,7 +143,7 @@ class TestToolsMsgMerge < Test::Unit::TestCase
96
143
  :msgstr => "",
97
144
  :references => pot_references)
98
145
 
99
- merged_po = @merger.merge(@po, @pot)
146
+ merged_po = merge
100
147
  assert_equal("bonjour", merged_po["hello"].msgstr)
101
148
  assert_equal(pot_references, merged_po["hello"].references)
102
149
  end
@@ -110,7 +157,7 @@ class TestToolsMsgMerge < Test::Unit::TestCase
110
157
  :msgstr => "",
111
158
  :flag => "no-c-format")
112
159
 
113
- merged_po = @merger.merge(@po, @pot)
160
+ merged_po = merge
114
161
  assert_equal("bonjour", merged_po["hello"].msgstr)
115
162
  assert_equal("no-c-format", merged_po["hello"].flag)
116
163
  end
@@ -123,7 +170,7 @@ class TestToolsMsgMerge < Test::Unit::TestCase
123
170
  @pot["hello"] = generate_entry(:msgid => "hello",
124
171
  :msgstr => "")
125
172
 
126
- merged_po = @merger.merge(@po, @pot)
173
+ merged_po = merge
127
174
  assert_equal("bonjour", merged_po["hello"].msgstr)
128
175
  assert_equal(nil, merged_po["hello"].previous)
129
176
  end
@@ -134,7 +181,7 @@ class TestToolsMsgMerge < Test::Unit::TestCase
134
181
  :msgstr => nil)
135
182
  @pot["hello"] = generate_entry(:msgid => "hello",
136
183
  :msgstr => nil)
137
- merged_po = @merger.merge(@po, @pot)
184
+ merged_po = merge
138
185
  assert_true(merged_po.has_key?("hello"))
139
186
  assert_nil(merged_po["hello"].flag)
140
187
  end
@@ -149,7 +196,7 @@ class TestToolsMsgMerge < Test::Unit::TestCase
149
196
  :translator_comment => "uninitialized comment",
150
197
  :flag => "fuzzy")
151
198
 
152
- merged_po = @merger.merge(@po, @pot)
199
+ merged_po = merge
153
200
  assert_equal("header\nentry", merged_po[""].msgstr)
154
201
  assert_equal("header comment", merged_po[""].translator_comment)
155
202
  assert_equal(nil, merged_po[""].flag)
@@ -168,7 +215,7 @@ class TestToolsMsgMerge < Test::Unit::TestCase
168
215
  :translator_comment => "header comment",
169
216
  :flag => "fuzzy")
170
217
 
171
- merged_po = @merger.merge(@po, @pot)
218
+ merged_po = merge
172
219
  assert_equal(pot_creation_date, merged_po[""].msgstr)
173
220
  end
174
221
  end
@@ -180,7 +227,7 @@ class TestToolsMsgMerge < Test::Unit::TestCase
180
227
  :msgstr => "salut")
181
228
  @pot["hello"] = generate_entry(:msgid => "hello",
182
229
  :msgstr => "")
183
- merged_po = @merger.merge(@po, @pot)
230
+ merged_po = merge
184
231
 
185
232
  assert_false(merged_po.has_key?("normal", "hello"))
186
233
  assert_true(merged_po.has_key?("hello"))
@@ -195,7 +242,7 @@ class TestToolsMsgMerge < Test::Unit::TestCase
195
242
  @pot["he"] = generate_entry(:msgid => "he",
196
243
  :msgid_plural => "they",
197
244
  :msgstr => "")
198
- merged_po = @merger.merge(@po, @pot)
245
+ merged_po = merge
199
246
 
200
247
  assert_equal("il\000ils", merged_po["he"].msgstr)
201
248
  assert_equal("they", merged_po["he"].msgid_plural)
@@ -205,7 +252,7 @@ class TestToolsMsgMerge < Test::Unit::TestCase
205
252
  def test_fuzzy_matching_entry
206
253
  @po["helol"] = "bonjour"
207
254
  @pot["hello"] = ""
208
- merged_po = @merger.merge(@po, @pot)
255
+ merged_po = merge
209
256
 
210
257
  assert_false(merged_po.has_key?("helol"))
211
258
  assert_true(merged_po.has_key?("hello"))
@@ -221,7 +268,7 @@ class TestToolsMsgMerge < Test::Unit::TestCase
221
268
  @pot["hello"] = generate_entry(:msgid => "hello",
222
269
  :msgstr => "")
223
270
 
224
- merged_po = @merger.merge(@po, @pot)
271
+ merged_po = merge
225
272
  assert_equal("bonjuor", merged_po["hello"].msgstr)
226
273
  assert_equal("fuzzy", merged_po["hello"].flag)
227
274
  end
@@ -230,7 +277,7 @@ class TestToolsMsgMerge < Test::Unit::TestCase
230
277
  def test_obsolete_entry
231
278
  @po["hello"] = "bonjour"
232
279
  @pot["hi"] = "salut"
233
- merged_po = @merger.merge(@po, @pot)
280
+ merged_po = merge
234
281
 
235
282
  assert_equal("salut", merged_po["hi"].msgstr)
236
283
  assert_false(merged_po.has_key?("hello"))
@@ -587,5 +634,61 @@ msgstr "Translated Hello World. This translation is very long. Yes! Very long tr
587
634
  PO
588
635
  end
589
636
  end
637
+
638
+ class TestFuzzyMatching < self
639
+ def pot_content
640
+ <<-POT
641
+ msgid "Hello"
642
+ msgstr ""
643
+ POT
644
+ end
645
+
646
+ def po_content
647
+ <<-PO
648
+ msgid "Hello!"
649
+ msgstr "Bonjour!"
650
+ PO
651
+ end
652
+
653
+ def test_default
654
+ @msgmerge.run("--update",
655
+ @po_file_path, @pot_file_path)
656
+ assert_equal(<<-PO, File.read(@po_file_path))
657
+ #, fuzzy
658
+ msgid "Hello"
659
+ msgstr "Bonjour!"
660
+
661
+ #~ msgid "Hello!"
662
+ #~ msgstr "Bonjour!"
663
+ PO
664
+ end
665
+
666
+ def test_fuzzy_matching
667
+ @msgmerge.run("--update",
668
+ "--fuzzy-matching",
669
+ @po_file_path, @pot_file_path)
670
+ assert_equal(<<-PO, File.read(@po_file_path))
671
+ #, fuzzy
672
+ msgid "Hello"
673
+ msgstr "Bonjour!"
674
+
675
+ #~ msgid "Hello!"
676
+ #~ msgstr "Bonjour!"
677
+ PO
678
+ end
679
+
680
+ def test_no_fuzzy_matching
681
+ @msgmerge.run("--update",
682
+ "--no-fuzzy-matching",
683
+ @po_file_path, @pot_file_path)
684
+ assert_equal(<<-PO, File.read(@po_file_path))
685
+ msgid "Hello"
686
+ msgstr ""
687
+
688
+ #~ msgid "Hello!"
689
+ #~ msgstr "Bonjour!"
690
+ PO
691
+ end
692
+ end
590
693
  end
591
694
  end
@@ -62,6 +62,7 @@ class TestToolsXGetText < Test::Unit::TestCase
62
62
  package_name = options[:package_name] || "PACKAGE"
63
63
  package_version = options[:package_version] || "VERSION"
64
64
  msgid_bugs_address = options[:msgid_bugs_address] || ""
65
+ copyright_year = options[:copyright_year] || "YEAR"
65
66
  copyright_holder = options[:copyright_holder] ||
66
67
  "THE PACKAGE'S COPYRIGHT HOLDER"
67
68
  output_encoding = options[:to_code] || "UTF-8"
@@ -69,9 +70,9 @@ class TestToolsXGetText < Test::Unit::TestCase
69
70
  time = @now.strftime("%Y-%m-%d %H:%M%z")
70
71
  <<-"EOH"
71
72
  # SOME DESCRIPTIVE TITLE.
72
- # Copyright (C) YEAR #{copyright_holder}
73
+ # Copyright (C) #{copyright_year} #{copyright_holder}
73
74
  # This file is distributed under the same license as the #{package_name} package.
74
- # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
75
+ # FIRST AUTHOR <EMAIL@ADDRESS>, #{copyright_year}.
75
76
  #
76
77
  #, fuzzy
77
78
  msgid ""
@@ -333,6 +334,14 @@ msgstr ""
333
334
  assert_equal(header(options), pot_content)
334
335
  end
335
336
 
337
+ def test_copyright_year
338
+ copyright_year = "2013"
339
+ pot_content = generate(":hello", "--copyright-year", copyright_year)
340
+
341
+ options = {:copyright_year => copyright_year}
342
+ assert_equal(header(options), pot_content)
343
+ end
344
+
336
345
  def test_copyright_holder
337
346
  copyright_holder = "me"
338
347
  pot_content = generate(":hello", "--copyright-holder", copyright_holder)
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gettext
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
5
- prerelease:
4
+ version: 3.0.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Kouhei Sutou
@@ -10,159 +9,138 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-09-29 00:00:00.000000000 Z
12
+ date: 2013-12-15 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: locale
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
- - - ! '>='
18
+ - - '>='
21
19
  - !ruby/object:Gem::Version
22
20
  version: 2.0.5
23
21
  type: :runtime
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
- - - ! '>='
25
+ - - '>='
29
26
  - !ruby/object:Gem::Version
30
27
  version: 2.0.5
31
28
  - !ruby/object:Gem::Dependency
32
29
  name: text
33
30
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
31
  requirements:
36
- - - ! '>='
32
+ - - '>='
37
33
  - !ruby/object:Gem::Version
38
34
  version: '0'
39
35
  type: :runtime
40
36
  prerelease: false
41
37
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
38
  requirements:
44
- - - ! '>='
39
+ - - '>='
45
40
  - !ruby/object:Gem::Version
46
41
  version: '0'
47
42
  - !ruby/object:Gem::Dependency
48
43
  name: rake
49
44
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
45
  requirements:
52
- - - ! '>='
46
+ - - '>='
53
47
  - !ruby/object:Gem::Version
54
48
  version: '0'
55
49
  type: :development
56
50
  prerelease: false
57
51
  version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
52
  requirements:
60
- - - ! '>='
53
+ - - '>='
61
54
  - !ruby/object:Gem::Version
62
55
  version: '0'
63
56
  - !ruby/object:Gem::Dependency
64
57
  name: racc
65
58
  requirement: !ruby/object:Gem::Requirement
66
- none: false
67
59
  requirements:
68
- - - ! '>='
60
+ - - '>='
69
61
  - !ruby/object:Gem::Version
70
62
  version: '0'
71
63
  type: :development
72
64
  prerelease: false
73
65
  version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
66
  requirements:
76
- - - ! '>='
67
+ - - '>='
77
68
  - !ruby/object:Gem::Version
78
69
  version: '0'
79
70
  - !ruby/object:Gem::Dependency
80
71
  name: yard
81
72
  requirement: !ruby/object:Gem::Requirement
82
- none: false
83
73
  requirements:
84
- - - ! '>='
74
+ - - '>='
85
75
  - !ruby/object:Gem::Version
86
76
  version: '0'
87
77
  type: :development
88
78
  prerelease: false
89
79
  version_requirements: !ruby/object:Gem::Requirement
90
- none: false
91
80
  requirements:
92
- - - ! '>='
81
+ - - '>='
93
82
  - !ruby/object:Gem::Version
94
83
  version: '0'
95
84
  - !ruby/object:Gem::Dependency
96
85
  name: redcarpet
97
86
  requirement: !ruby/object:Gem::Requirement
98
- none: false
99
87
  requirements:
100
- - - ! '>='
88
+ - - '>='
101
89
  - !ruby/object:Gem::Version
102
90
  version: '0'
103
91
  type: :development
104
92
  prerelease: false
105
93
  version_requirements: !ruby/object:Gem::Requirement
106
- none: false
107
94
  requirements:
108
- - - ! '>='
95
+ - - '>='
109
96
  - !ruby/object:Gem::Version
110
97
  version: '0'
111
98
  - !ruby/object:Gem::Dependency
112
99
  name: test-unit
113
100
  requirement: !ruby/object:Gem::Requirement
114
- none: false
115
101
  requirements:
116
- - - ! '>='
102
+ - - '>='
117
103
  - !ruby/object:Gem::Version
118
104
  version: '0'
119
105
  type: :development
120
106
  prerelease: false
121
107
  version_requirements: !ruby/object:Gem::Requirement
122
- none: false
123
108
  requirements:
124
- - - ! '>='
109
+ - - '>='
125
110
  - !ruby/object:Gem::Version
126
111
  version: '0'
127
112
  - !ruby/object:Gem::Dependency
128
113
  name: test-unit-notify
129
114
  requirement: !ruby/object:Gem::Requirement
130
- none: false
131
115
  requirements:
132
- - - ! '>='
116
+ - - '>='
133
117
  - !ruby/object:Gem::Version
134
118
  version: '0'
135
119
  type: :development
136
120
  prerelease: false
137
121
  version_requirements: !ruby/object:Gem::Requirement
138
- none: false
139
122
  requirements:
140
- - - ! '>='
123
+ - - '>='
141
124
  - !ruby/object:Gem::Version
142
125
  version: '0'
143
126
  - !ruby/object:Gem::Dependency
144
127
  name: test-unit-rr
145
128
  requirement: !ruby/object:Gem::Requirement
146
- none: false
147
129
  requirements:
148
- - - ! '>='
130
+ - - '>='
149
131
  - !ruby/object:Gem::Version
150
132
  version: '0'
151
133
  type: :development
152
134
  prerelease: false
153
135
  version_requirements: !ruby/object:Gem::Requirement
154
- none: false
155
136
  requirements:
156
- - - ! '>='
137
+ - - '>='
157
138
  - !ruby/object:Gem::Version
158
139
  version: '0'
159
- description: ! 'Gettext is a GNU gettext-like program for Ruby.
160
-
140
+ description: |
141
+ Gettext is a GNU gettext-like program for Ruby.
161
142
  The catalog file(po-file) is same format with GNU gettext.
162
-
163
143
  So you can use GNU gettext tools for maintaining.
164
-
165
- '
166
144
  email:
167
145
  - kou@clear-code.com
168
146
  - mutomasa at gmail.com
@@ -1011,27 +989,26 @@ files:
1011
989
  homepage: http://ruby-gettext.github.com/
1012
990
  licenses:
1013
991
  - Ruby or LGPLv3+
992
+ metadata: {}
1014
993
  post_install_message:
1015
994
  rdoc_options: []
1016
995
  require_paths:
1017
996
  - lib
1018
997
  required_ruby_version: !ruby/object:Gem::Requirement
1019
- none: false
1020
998
  requirements:
1021
- - - ! '>='
999
+ - - '>='
1022
1000
  - !ruby/object:Gem::Version
1023
1001
  version: '0'
1024
1002
  required_rubygems_version: !ruby/object:Gem::Requirement
1025
- none: false
1026
1003
  requirements:
1027
- - - ! '>='
1004
+ - - '>='
1028
1005
  - !ruby/object:Gem::Version
1029
1006
  version: '0'
1030
1007
  requirements: []
1031
1008
  rubyforge_project: gettext
1032
- rubygems_version: 1.8.23
1009
+ rubygems_version: 2.0.14
1033
1010
  signing_key:
1034
- specification_version: 3
1011
+ specification_version: 4
1035
1012
  summary: Gettext is a pure Ruby libary and tools to localize messages.
1036
1013
  test_files:
1037
1014
  - test/test_po.rb