gettext 2.3.9 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. data/.yardopts +1 -0
  2. data/README.rdoc +28 -23
  3. data/Rakefile +29 -21
  4. data/doc/text/news.md +57 -0
  5. data/gettext.gemspec +1 -1
  6. data/lib/gettext.rb +13 -29
  7. data/lib/gettext/cgi.rb +1 -1
  8. data/lib/gettext/{runtime/class_info.rb → class_info.rb} +1 -1
  9. data/lib/gettext/{runtime/locale_path.rb → locale_path.rb} +1 -2
  10. data/lib/gettext/{runtime/mo.rb → mo.rb} +18 -33
  11. data/lib/gettext/{tools/po.rb → po.rb} +1 -1
  12. data/lib/gettext/{tools/po_entry.rb → po_entry.rb} +8 -4
  13. data/lib/gettext/{tools/poparser.rb → po_parser.rb} +41 -44
  14. data/lib/gettext/{runtime/textdomain.rb → text_domain.rb} +6 -16
  15. data/lib/gettext/text_domain_group.rb +26 -0
  16. data/lib/gettext/{runtime/textdomain_manager.rb → text_domain_manager.rb} +40 -40
  17. data/lib/gettext/tools.rb +1 -182
  18. data/lib/gettext/tools/msgfmt.rb +1 -1
  19. data/lib/gettext/tools/msginit.rb +1 -1
  20. data/lib/gettext/tools/msgmerge.rb +2 -221
  21. data/lib/gettext/tools/parser/erb.rb +49 -30
  22. data/lib/gettext/tools/parser/glade.rb +44 -36
  23. data/lib/gettext/tools/parser/ruby.rb +126 -37
  24. data/lib/gettext/tools/task.rb +225 -0
  25. data/lib/gettext/tools/xgettext.rb +25 -28
  26. data/lib/gettext/version.rb +1 -1
  27. data/locale/bg/LC_MESSAGES/gettext.mo +0 -0
  28. data/locale/bs/LC_MESSAGES/gettext.mo +0 -0
  29. data/locale/ca/LC_MESSAGES/gettext.mo +0 -0
  30. data/locale/cs/LC_MESSAGES/gettext.mo +0 -0
  31. data/locale/de/LC_MESSAGES/gettext.mo +0 -0
  32. data/locale/el/LC_MESSAGES/gettext.mo +0 -0
  33. data/locale/eo/LC_MESSAGES/gettext.mo +0 -0
  34. data/locale/es/LC_MESSAGES/gettext.mo +0 -0
  35. data/locale/et/LC_MESSAGES/gettext.mo +0 -0
  36. data/locale/fr/LC_MESSAGES/gettext.mo +0 -0
  37. data/locale/hr/LC_MESSAGES/gettext.mo +0 -0
  38. data/locale/hu/LC_MESSAGES/gettext.mo +0 -0
  39. data/locale/it/LC_MESSAGES/gettext.mo +0 -0
  40. data/locale/ja/LC_MESSAGES/gettext.mo +0 -0
  41. data/locale/ko/LC_MESSAGES/gettext.mo +0 -0
  42. data/locale/lv/LC_MESSAGES/gettext.mo +0 -0
  43. data/locale/nb/LC_MESSAGES/gettext.mo +0 -0
  44. data/locale/nl/LC_MESSAGES/gettext.mo +0 -0
  45. data/locale/pt_BR/LC_MESSAGES/gettext.mo +0 -0
  46. data/locale/ru/LC_MESSAGES/gettext.mo +0 -0
  47. data/locale/sr/LC_MESSAGES/gettext.mo +0 -0
  48. data/locale/sv/LC_MESSAGES/gettext.mo +0 -0
  49. data/locale/uk/LC_MESSAGES/gettext.mo +0 -0
  50. data/locale/vi/LC_MESSAGES/gettext.mo +0 -0
  51. data/locale/zh/LC_MESSAGES/gettext.mo +0 -0
  52. data/locale/zh_TW/LC_MESSAGES/gettext.mo +0 -0
  53. data/po/gettext.pot +171 -97
  54. data/samples/hello.rb +3 -2
  55. data/samples/hello2.rb +2 -1
  56. data/samples/hello_gtk2.rb +4 -1
  57. data/samples/hello_gtk_builder.rb +32 -0
  58. data/samples/hello_gtk_builder.ui +46 -0
  59. data/samples/hello_noop.rb +2 -1
  60. data/samples/hello_plural.rb +2 -1
  61. data/samples/hello_tk.rb +2 -1
  62. data/src/{poparser.ry → po_parser.ry} +31 -35
  63. data/test/fixtures/N_.rb +1 -1
  64. data/test/fixtures/_/double_quote_in_double_quote.rb +32 -0
  65. data/test/fixtures/_/double_quote_in_single_quote.rb +32 -0
  66. data/test/fixtures/_/literal_concatenation_with_continuation_line.rb +36 -0
  67. data/test/fixtures/_/middle_new_line.rb +32 -0
  68. data/test/fixtures/_/multiple_lines_literal.rb +35 -0
  69. data/test/fixtures/_/multiple_messages_in_same_line.rb +32 -0
  70. data/test/fixtures/_/multiple_same_messages.rb +36 -0
  71. data/{lib/gettext/runtime/mofile.rb → test/fixtures/_/one_new_line.rb} +12 -6
  72. data/test/fixtures/{multi_textdomain.rb → multi_text_domain.rb} +1 -1
  73. data/test/fixtures/non_ascii.rb +1 -1
  74. data/test/fixtures/simple.rb +1 -1
  75. data/test/fixtures/untranslated.rb +1 -1
  76. data/test/gettext-test-utils.rb +1 -24
  77. data/test/po/ja/_.po +63 -13
  78. data/test/po/ja/non_ascii.po +2 -3
  79. data/test/po/ja/untranslated.po +1 -1
  80. data/test/test_class_info.rb +2 -2
  81. data/test/test_gettext.rb +11 -11
  82. data/test/test_mo.rb +2 -2
  83. data/test/test_parser.rb +93 -96
  84. data/test/test_po_entry.rb +237 -146
  85. data/test/test_po_parser.rb +107 -98
  86. data/test/test_string.rb +1 -1
  87. data/test/{test_textdomain_bind.rb → test_text_domain_bind.rb} +6 -6
  88. data/test/{test_textdomain_multi.rb → test_text_domain_multi.rb} +5 -5
  89. data/test/{test_textdomain_toplevel.rb → test_text_domain_toplevel.rb} +1 -1
  90. data/test/test_thread.rb +1 -1
  91. data/test/tools/files/simple_translation.rb +1 -1
  92. data/test/{parser → tools/parser}/test_ruby.rb +110 -14
  93. data/test/tools/test_msgmerge.rb +17 -276
  94. data/test/tools/test_po.rb +1 -1
  95. data/test/tools/test_xgettext.rb +175 -144
  96. metadata +59 -33
  97. data/lib/gettext/core_ext/iconv.rb +0 -110
  98. data/lib/gettext/core_ext/string.rb +0 -91
  99. data/lib/gettext/parser/erb.rb +0 -5
  100. data/lib/gettext/parser/glade.rb +0 -5
  101. data/lib/gettext/parser/ruby.rb +0 -172
  102. data/lib/gettext/runtime/textdomain_group.rb +0 -26
  103. data/lib/gettext/task.rb +0 -203
  104. data/lib/gettext/utils.rb +0 -39
  105. data/test/test_po_generation.rb +0 -45
  106. data/test/tools/test_tools.rb +0 -61
@@ -1,10 +1,27 @@
1
- # encoding: utf-8
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # Copyright (C) 2012 Haruka Yoshihara <yoshihara@clear-code.com>
4
+ # Copyright (C) 2012-2013 Kouhei Sutou <kou@clear-code.com>
5
+ # Copyright (C) 2010 masone (Christian Felder) <ema@rh-productions.ch>
6
+ # Copyright (C) 2009 Masao Mutoh
7
+ #
8
+ # License: Ruby's or LGPL
9
+ #
10
+ # This library is free software: you can redistribute it and/or modify
11
+ # it under the terms of the GNU Lesser General Public License as published by
12
+ # the Free Software Foundation, either version 3 of the License, or
13
+ # (at your option) any later version.
14
+ #
15
+ # This library is distributed in the hope that it will be useful,
16
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ # GNU Lesser General Public License for more details.
19
+ #
20
+ # You should have received a copy of the GNU Lesser General Public License
21
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
2
22
 
3
23
  require 'gettext/tools/parser/ruby'
4
24
 
5
- # Most functionality of PoMessage is thoroughly tested together
6
- # with the parser and po file generator. Here only tests for some special
7
- # functionality.
8
25
  class TestPOEntry < Test::Unit::TestCase
9
26
 
10
27
  def test_context_match
@@ -53,151 +70,219 @@ class TestPOEntry < Test::Unit::TestCase
53
70
  end
54
71
 
55
72
  class TestToS < self
56
- def test_normal
57
- po = GetText::POEntry.new(:normal)
58
- po.msgid = 'hello'
59
- po.references = ["file1:1", "file2:10"]
60
- assert_equal "#: file1:1 file2:10\nmsgid \"hello\"\nmsgstr \"\"\n", po.to_s
61
-
62
- po.msgctxt = 'context'
63
- po.msgid_plural = 'hello2'
64
- # Ignore these properties.
65
- assert_equal "#: file1:1 file2:10\nmsgid \"hello\"\nmsgstr \"\"\n", po.to_s
73
+ class TestNormal < self
74
+ def setup
75
+ @entry = GetText::POEntry.new(:normal)
76
+ end
77
+
78
+ def test_minimum
79
+ @entry.msgid = 'hello'
80
+ @entry.references = ["file1:1", "file2:10"]
81
+ assert_equal(<<-PO, @entry.to_s)
82
+ #: file1:1 file2:10
83
+ msgid "hello"
84
+ msgstr ""
85
+ PO
86
+ end
87
+
88
+ def test_with_garbage_information
89
+ @entry.msgid = 'hello'
90
+ @entry.references = ["file1:1", "file2:10"]
91
+ @entry.msgctxt = 'context'
92
+ @entry.msgid_plural = 'hello2'
93
+ assert_equal(<<-PO, @entry.to_s)
94
+ #: file1:1 file2:10
95
+ msgid "hello"
96
+ msgstr ""
97
+ PO
98
+ end
99
+
100
+ def test_new_line
101
+ @entry.msgid = "hello\nworld"
102
+ assert_equal(<<-PO, @entry.to_s)
103
+ msgid ""
104
+ "hello\\n"
105
+ "world"
106
+ msgstr ""
107
+ PO
108
+ end
66
109
  end
67
110
 
68
- def test_plural
69
- po = GetText::POEntry.new(:plural)
70
- po.msgid = 'hello'
71
- po.msgid_plural = 'hello2'
72
- po.references = ["file1:1", "file2:10"]
73
- assert_equal "#: file1:1 file2:10\nmsgid \"hello\"\nmsgid_plural \"hello2\"\nmsgstr[0] \"\"\nmsgstr[1] \"\"\n", po.to_s
111
+ class TestPlural < self
112
+ def setup
113
+ @entry = GetText::POEntry.new(:plural)
114
+ end
115
+
116
+ def test_minimum
117
+ @entry.msgid = 'hello'
118
+ @entry.msgid_plural = 'hello2'
119
+ @entry.references = ["file1:1", "file2:10"]
120
+ assert_equal(<<-PO, @entry.to_s)
121
+ #: file1:1 file2:10
122
+ msgid "hello"
123
+ msgid_plural "hello2"
124
+ msgstr[0] ""
125
+ msgstr[1] ""
126
+ PO
127
+ end
74
128
 
75
- po.msgctxt = 'context'
76
- # Ignore this property
77
- assert_equal "#: file1:1 file2:10\nmsgid \"hello\"\nmsgid_plural \"hello2\"\nmsgstr[0] \"\"\nmsgstr[1] \"\"\n", po.to_s
129
+ def test_with_garbage_information
130
+ @entry.msgid = 'hello'
131
+ @entry.msgid_plural = 'hello2'
132
+ @entry.references = ["file1:1", "file2:10"]
133
+ @entry.msgctxt = 'context'
134
+ assert_equal(<<-PO, @entry.to_s)
135
+ #: file1:1 file2:10
136
+ msgid "hello"
137
+ msgid_plural "hello2"
138
+ msgstr[0] ""
139
+ msgstr[1] ""
140
+ PO
141
+ end
78
142
  end
79
143
 
80
144
  def test_msgctxt
81
- po = GetText::POEntry.new(:msgctxt)
82
- po.msgctxt = 'context'
83
- po.msgid = 'hello'
84
- po.references = ["file1:1", "file2:10"]
85
- assert_equal "#: file1:1 file2:10\nmsgctxt \"context\"\nmsgid \"hello\"\nmsgstr \"\"\n", po.to_s
145
+ entry = GetText::POEntry.new(:msgctxt)
146
+ entry.msgctxt = 'context'
147
+ entry.msgid = 'hello'
148
+ entry.references = ["file1:1", "file2:10"]
149
+ assert_equal(<<-PO, entry.to_s)
150
+ #: file1:1 file2:10
151
+ msgctxt "context"
152
+ msgid "hello"
153
+ msgstr ""
154
+ PO
86
155
  end
87
156
 
88
157
  def test_msgctxt_plural
89
- po = GetText::POEntry.new(:msgctxt_plural)
90
- po.msgctxt = 'context'
91
- po.msgid = 'hello'
92
- po.msgid_plural = 'hello2'
93
- po.references = ["file1:1", "file2:10"]
94
- assert_equal "#: file1:1 file2:10\nmsgctxt \"context\"\nmsgid \"hello\"\nmsgid_plural \"hello2\"\nmsgstr[0] \"\"\nmsgstr[1] \"\"\n", po.to_s
158
+ entry = GetText::POEntry.new(:msgctxt_plural)
159
+ entry.msgctxt = 'context'
160
+ entry.msgid = 'hello'
161
+ entry.msgid_plural = 'hello2'
162
+ entry.references = ["file1:1", "file2:10"]
163
+ assert_equal(<<-PO, entry.to_s)
164
+ #: file1:1 file2:10
165
+ msgctxt "context"
166
+ msgid "hello"
167
+ msgid_plural "hello2"
168
+ msgstr[0] ""
169
+ msgstr[1] ""
170
+ PO
95
171
  end
96
172
 
97
- def test_exception
98
- po = GetText::POEntry.new(:normal)
99
- po.references = ["file1:1", "file2:10"]
100
- assert_raise(GetText::POEntry::NoMsgidError) {po.to_s}
101
-
102
- po.references = nil
103
- assert_raise(GetText::POEntry::NoMsgidError) {po.to_s}
104
-
105
- po = GetText::POEntry.new(:plural)
106
- po.msgid = 'hello'
107
- po.references = ["file1:1", "file2:10"]
108
- assert_raise(GetText::POEntry::NoMsgidPluralError) {po.to_s}
109
-
110
- po = GetText::POEntry.new(:msgctxt)
111
- po.msgid = 'hello'
112
- po.references = ["file1:1", "file2:10"]
113
- assert_raise(GetText::POEntry::NoMsgctxtError) {po.to_s}
114
-
115
- po = GetText::POEntry.new(:msgctxt_plural)
116
- po.msgctxt = 'context'
117
- po.msgid = 'hello'
118
- po.references = ["file1:1", "file2:10"]
119
- assert_raise(GetText::POEntry::NoMsgidPluralError) {po.to_s}
173
+ class TestInvalid < self
174
+ def test_normal
175
+ entry = GetText::POEntry.new(:normal)
176
+ entry.references = ["file1:1", "file2:10"]
177
+ assert_raise(GetText::POEntry::NoMsgidError) {entry.to_s}
178
+ end
179
+
180
+ def test_plural
181
+ entry = GetText::POEntry.new(:plural)
182
+ entry.msgid = 'hello'
183
+ entry.references = ["file1:1", "file2:10"]
184
+ assert_raise(GetText::POEntry::NoMsgidPluralError) {entry.to_s}
185
+ end
186
+
187
+ def test_msgctxt
188
+ entry = GetText::POEntry.new(:msgctxt)
189
+ entry.msgid = 'hello'
190
+ entry.references = ["file1:1", "file2:10"]
191
+ assert_raise(GetText::POEntry::NoMsgctxtError) {entry.to_s}
192
+ end
193
+
194
+ def test_msgctx_plural
195
+ entry = GetText::POEntry.new(:msgctxt_plural)
196
+ entry.msgctxt = 'context'
197
+ entry.msgid = 'hello'
198
+ entry.references = ["file1:1", "file2:10"]
199
+ assert_raise(GetText::POEntry::NoMsgidPluralError) {entry.to_s}
200
+ end
120
201
  end
121
202
 
122
203
  def test_header
123
- po = GetText::POEntry.new(:normal)
124
- po.msgid = ""
125
- po.msgstr = "This is the header entry."
126
- po.references = nil
127
- expected_header = <<EOH
204
+ entry = GetText::POEntry.new(:normal)
205
+ entry.msgid = ""
206
+ entry.msgstr = "This is the header entry."
207
+ entry.references = nil
208
+ expected_header = <<-EOH
128
209
  msgid ""
129
210
  msgstr "This is the header entry."
130
211
  EOH
131
- assert_equal(expected_header, po.to_s)
212
+ assert_equal(expected_header, entry.to_s)
132
213
  end
133
214
 
134
- def test_msgstr
135
- po = GetText::POEntry.new(:normal)
136
- po.msgid = "hello"
137
- po.msgstr = "Bonjour"
138
- po.references = ["file1:1", "file2:10"]
139
- expected_entry = <<-EOE
215
+ class TestMessageString < self
216
+ def test_normal
217
+ entry = GetText::POEntry.new(:normal)
218
+ entry.msgid = "hello"
219
+ entry.msgstr = "Bonjour"
220
+ entry.references = ["file1:1", "file2:10"]
221
+ expected_po = <<-EOE
140
222
  #: file1:1 file2:10
141
223
  msgid "hello"
142
224
  msgstr "Bonjour"
143
225
  EOE
144
- assert_equal(expected_entry, po.to_s)
145
- end
226
+ assert_equal(expected_po, entry.to_s)
227
+ end
146
228
 
147
- def test_escaped_msgstr
148
- po = GetText::POEntry.new(:normal)
149
- po.msgid = "He said \"hello.\""
150
- po.msgstr = "Il a dit \"bonjour.\""
151
- po.references = ["file1:1", "file2:10"]
152
- expected_entry = <<-EOE
229
+ def test_plural
230
+ entry = GetText::POEntry.new(:plural)
231
+ entry.msgid = "he"
232
+ entry.msgid_plural = "them"
233
+ entry.msgstr = "il\000ils"
234
+ entry.references = ["file1:1", "file2:10"]
235
+ expected_po = <<-EOE
153
236
  #: file1:1 file2:10
154
- msgid "He said \\\"hello.\\\""
155
- msgstr "Il a dit \\\"bonjour.\\\""
237
+ msgid "he"
238
+ msgid_plural "them"
239
+ msgstr[0] "il"
240
+ msgstr[1] "ils"
156
241
  EOE
157
- assert_equal(expected_entry, po.to_s)
158
- end
242
+ assert_equal(expected_po, entry.to_s)
243
+ end
159
244
 
160
- def test_escaped_msgstr_with_msgid_plural
161
- po = GetText::POEntry.new(:plural)
162
- po.msgid = "He said \"hello.\""
163
- po.msgid_plural = "They said \"hello.\""
164
- po.msgstr = "Il a dit \"bonjour.\"\000Ils ont dit \"bonjour.\""
165
- po.references = ["file1:1", "file2:10"]
166
- expected_entry = <<-EOE
245
+ class TestEscape < self
246
+ def test_normal
247
+ entry = GetText::POEntry.new(:normal)
248
+ entry.msgid = "He said \"hello.\""
249
+ entry.msgstr = "Il a dit \"bonjour.\""
250
+ entry.references = ["file1:1", "file2:10"]
251
+ expected_po = <<-EOE
167
252
  #: file1:1 file2:10
168
- msgid "He said \\\"hello.\\\""
169
- msgid_plural "They said \\\"hello.\\\""
170
- msgstr[0] "Il a dit \\\"bonjour.\\\""
171
- msgstr[1] "Ils ont dit \\\"bonjour.\\\""
253
+ msgid "He said \\"hello.\\""
254
+ msgstr "Il a dit \\"bonjour.\\""
172
255
  EOE
173
- assert_equal(expected_entry, po.to_s)
174
- end
175
-
176
- def test_msgstr_with_msgid_plural
177
- po = GetText::POEntry.new(:plural)
178
- po.msgid = "he"
179
- po.msgid_plural = "them"
180
- po.msgstr = "il\000ils"
181
- po.references = ["file1:1", "file2:10"]
182
- expected_entry = <<-EOE
256
+ assert_equal(expected_po, entry.to_s)
257
+ end
258
+
259
+ def test_plural
260
+ entry = GetText::POEntry.new(:plural)
261
+ entry.msgid = "He said \"hello.\""
262
+ entry.msgid_plural = "They said \"hello.\""
263
+ entry.msgstr = "Il a dit \"bonjour.\"\000Ils ont dit \"bonjour.\""
264
+ entry.references = ["file1:1", "file2:10"]
265
+ expected_po = <<-EOE
183
266
  #: file1:1 file2:10
184
- msgid "he"
185
- msgid_plural "them"
186
- msgstr[0] "il"
187
- msgstr[1] "ils"
267
+ msgid "He said \\"hello.\\""
268
+ msgid_plural "They said \\"hello.\\""
269
+ msgstr[0] "Il a dit \\"bonjour.\\""
270
+ msgstr[1] "Ils ont dit \\"bonjour.\\""
188
271
  EOE
189
- assert_equal(expected_entry, po.to_s)
272
+ assert_equal(expected_po, entry.to_s)
273
+ end
274
+ end
190
275
  end
191
276
 
192
277
  def test_obsolete_comment
193
- po = GetText::POEntry.new(:normal)
194
- po.msgid = :last
195
- obsolete_comment =<<EOC
278
+ entry = GetText::POEntry.new(:normal)
279
+ entry.msgid = :last
280
+ obsolete_comment = <<-EOC
196
281
  # test.rb:10
197
- msgid \"hello\"
198
- msgstr \"Salut\"
282
+ msgid "hello"
283
+ msgstr "Salut"
199
284
  EOC
200
- po.comment = obsolete_comment
285
+ entry.comment = obsolete_comment
201
286
 
202
287
  expected_obsolete_comment = <<-EOC
203
288
  # test.rb:10
@@ -205,69 +290,69 @@ EOC
205
290
  #~ msgstr "Salut"
206
291
  EOC
207
292
 
208
- assert_equal(expected_obsolete_comment, po.to_s)
293
+ assert_equal(expected_obsolete_comment, entry.to_s)
209
294
  end
210
295
 
211
296
  def test_translator_comment
212
- po = GetText::POEntry.new(:normal)
213
- po.msgid = "msgid"
214
- po.msgstr = "msgstr"
215
- po.translator_comment = "It's the translator comment."
297
+ entry = GetText::POEntry.new(:normal)
298
+ entry.msgid = "msgid"
299
+ entry.msgstr = "msgstr"
300
+ entry.translator_comment = "It's the translator comment."
216
301
 
217
- expected_po =<<EOP
302
+ expected_po = <<-EOP
218
303
  # It's the translator comment.
219
- msgid \"msgid\"
220
- msgstr \"msgstr\"
304
+ msgid "msgid"
305
+ msgstr "msgstr"
221
306
  EOP
222
- assert_equal(expected_po, po.to_s)
307
+ assert_equal(expected_po, entry.to_s)
223
308
  end
224
309
 
225
310
  def test_extracted_comment
226
- po = GetText::POEntry.new(:normal)
227
- po.msgid = "msgid"
228
- po.msgstr = "msgstr"
229
- po.extracted_comment = "It's the extracted comment."
311
+ entry = GetText::POEntry.new(:normal)
312
+ entry.msgid = "msgid"
313
+ entry.msgstr = "msgstr"
314
+ entry.extracted_comment = "It's the extracted comment."
230
315
 
231
- expected_po =<<EOP
316
+ expected_po = <<-EOP
232
317
  #. It's the extracted comment.
233
- msgid \"msgid\"
234
- msgstr \"msgstr\"
318
+ msgid "msgid"
319
+ msgstr "msgstr"
235
320
  EOP
236
- assert_equal(expected_po, po.to_s)
321
+ assert_equal(expected_po, entry.to_s)
237
322
  end
238
323
 
239
324
  def test_flag
240
- po = GetText::POEntry.new(:normal)
241
- po.msgid = "msgid"
242
- po.msgstr = "msgstr"
243
- po.flag = "It's the flag."
325
+ entry = GetText::POEntry.new(:normal)
326
+ entry.msgid = "msgid"
327
+ entry.msgstr = "msgstr"
328
+ entry.flag = "It's the flag."
244
329
 
245
- expected_po =<<EOP
330
+ expected_po = <<-EOP
246
331
  #, It's the flag.
247
- msgid \"msgid\"
248
- msgstr \"msgstr\"
332
+ msgid "msgid"
333
+ msgstr "msgstr"
249
334
  EOP
250
- assert_equal(expected_po, po.to_s)
335
+ assert_equal(expected_po, entry.to_s)
251
336
  end
252
337
 
253
338
  def test_previous
254
- po = GetText::POEntry.new(:normal)
255
- po.msgid = "msgid"
256
- po.msgstr = "msgstr"
257
- po.previous = <<EOC
339
+ entry = GetText::POEntry.new(:normal)
340
+ entry.msgid = "msgid"
341
+ entry.msgstr = "msgstr"
342
+ entry.previous = <<-EOC
258
343
  msgctxt previous_msgctxt
259
344
  msgid previous_msgid
260
345
  msgid_plural previous_msgid_plural
261
346
  EOC
262
347
 
263
- expected_po =<<EOP
348
+ expected_po = <<-EOP
264
349
  #| msgctxt previous_msgctxt
265
350
  #| msgid previous_msgid
266
351
  #| msgid_plural previous_msgid_plural
267
- msgid \"msgid\"
268
- msgstr \"msgstr\"
352
+ msgid "msgid"
353
+ msgstr "msgstr"
269
354
  EOP
270
- assert_equal(expected_po, po.to_s)
355
+ assert_equal(expected_po, entry.to_s)
271
356
  end
272
357
  end
273
358
 
@@ -287,6 +372,12 @@ EOP
287
372
  assert_equal("First\\nSecond\\nThird",
288
373
  @entry.escaped(:msgid))
289
374
  end
375
+
376
+ def test_tab
377
+ @entry.msgid = "First\tSecond\tThird"
378
+ assert_equal("First\\tSecond\\tThird",
379
+ @entry.escaped(:msgid))
380
+ end
290
381
  end
291
382
 
292
383
  class TestFormatMessage < self