gettext 3.0.2 → 3.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -103,7 +103,18 @@ module GetText
103
103
  #
104
104
  # @return [String] Text domain
105
105
  attr_accessor :domain
106
+
107
+ # It is useful when you have multiple domains. You can define tasks
108
+ # for each domains by using different namespace prefix.
109
+ #
110
+ # It is `nil` by default. It means that tasks are defined at top
111
+ # level.
112
+ #
113
+ # TODO: example
114
+ #
115
+ # @return [String] Namespace prefix for tasks defined by this class.
106
116
  attr_accessor :namespace_prefix
117
+
107
118
  # @return [Array<String>] Command line options for extracting messages
108
119
  # from sources.
109
120
  # @see GetText::Tools::XGetText
@@ -24,6 +24,7 @@ require "pathname"
24
24
  require "optparse"
25
25
  require "locale"
26
26
  require "gettext"
27
+ require "gettext/po"
27
28
 
28
29
  module GetText
29
30
  module Tools
@@ -78,11 +79,12 @@ module GetText
78
79
  @input_files = nil
79
80
  @output = nil
80
81
 
81
- @package_name = nil
82
- @package_version = nil
83
- @msgid_bugs_address = nil
84
- @copyright_holder = nil
85
- @output_encoding = nil
82
+ @package_name = "PACKAGE"
83
+ @package_version = "VERSION"
84
+ @msgid_bugs_address = ""
85
+ @copyright_holder = "THE PACKAGE'S COPYRIGHT HOLDER"
86
+ @copyright_year = "YEAR"
87
+ @output_encoding = "UTF-8"
86
88
 
87
89
  @parse_options = {}
88
90
 
@@ -146,7 +148,6 @@ module GetText
146
148
  def run(*options) # :nodoc:
147
149
  check_command_line_options(*options)
148
150
 
149
- @output_encoding ||= "UTF-8"
150
151
  pot = generate_pot(@input_files)
151
152
 
152
153
  if @output.is_a?(String)
@@ -181,9 +182,9 @@ module GetText
181
182
  def header_comment
182
183
  <<-COMMENT
183
184
  SOME DESCRIPTIVE TITLE.
184
- Copyright (C) YEAR #{@copyright_holder}
185
+ Copyright (C) #{@copyright_year} #{@copyright_holder}
185
186
  This file is distributed under the same license as the #{@package_name} package.
186
- FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
187
+ FIRST AUTHOR <EMAIL@ADDRESS>, #{@copyright_year}.
187
188
 
188
189
  COMMENT
189
190
  end
@@ -232,11 +233,6 @@ Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;
232
233
 
233
234
  @input_files = input_files
234
235
  @output = output
235
-
236
- @package_name ||= "PACKAGE"
237
- @package_version ||= "VERSION"
238
- @msgid_bugs_address ||= ""
239
- @copyright_holder ||= "THE PACKAGE'S COPYRIGHT HOLDER"
240
236
  end
241
237
 
242
238
  def parse_arguments(*options) #:nodoc:
@@ -256,28 +252,39 @@ Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;
256
252
  output = out
257
253
  end
258
254
 
259
- parser.on("--package-name=PACKAGE",
260
- _("set package name in output")) do |out|
261
- @package_name = out
255
+ parser.on("--package-name=NAME",
256
+ _("set package name in output"),
257
+ "(#{@package_name})") do |name|
258
+ @package_name = name
262
259
  end
263
260
 
264
261
  parser.on("--package-version=VERSION",
265
- _("set package version in output")) do |out|
266
- @package_version = out
262
+ _("set package version in output"),
263
+ "(#{@package_version})") do |version|
264
+ @package_version = version
267
265
  end
268
266
 
269
267
  parser.on("--msgid-bugs-address=EMAIL",
270
- _("set report address for msgid bugs")) do |out|
271
- @msgid_bugs_address = out
268
+ _("set report e-mail address for msgid bugs"),
269
+ "(#{@msgid_bugs_address})") do |address|
270
+ @msgid_bugs_address = address
271
+ end
272
+
273
+ parser.on("--copyright-holder=HOLDER",
274
+ _("set copyright holder in output"),
275
+ "(#{@copyright_holder})") do |holder|
276
+ @copyright_holder = holder
272
277
  end
273
278
 
274
- parser.on("--copyright-holder=STRING",
275
- _("set copyright holder in output")) do |out|
276
- @copyright_holder = out
279
+ parser.on("--copyright-year=YEAR",
280
+ _("set copyright year in output"),
281
+ "(#{@copyright_year})") do |year|
282
+ @copyright_year = year
277
283
  end
278
284
 
279
285
  parser.on("--output-encoding=ENCODING",
280
- _("set encoding for output")) do |encoding|
286
+ _("set encoding for output"),
287
+ "(#{@output_encoding})") do |encoding|
281
288
  @output_encoding = encoding
282
289
  end
283
290
 
@@ -9,5 +9,5 @@
9
9
  =end
10
10
 
11
11
  module GetText
12
- VERSION = "3.0.2"
12
+ VERSION = "3.0.3"
13
13
  end
data/po/gettext.pot CHANGED
@@ -6,10 +6,10 @@
6
6
  #, fuzzy
7
7
  msgid ""
8
8
  msgstr ""
9
- "Project-Id-Version: gettext 3.0.2\n"
9
+ "Project-Id-Version: gettext 3.0.3\n"
10
10
  "Report-Msgid-Bugs-To: \n"
11
- "POT-Creation-Date: 2013-09-29 12:01+0900\n"
12
- "PO-Revision-Date: 2013-09-29 12:01+0900\n"
11
+ "POT-Creation-Date: 2013-12-15 16:24+0900\n"
12
+ "PO-Revision-Date: 2013-12-15 16:24+0900\n"
13
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
15
15
  "Language: \n"
@@ -39,15 +39,15 @@ msgid "Generate binary message catalog from textual translation description."
39
39
  msgstr ""
40
40
 
41
41
  #: ../lib/gettext/tools/msgfmt.rb:86 ../lib/gettext/tools/msginit.rb:89
42
- #: ../lib/gettext/tools/msgmerge.rb:266 ../lib/gettext/tools/xgettext.rb:252
42
+ #: ../lib/gettext/tools/msgmerge.rb:319 ../lib/gettext/tools/xgettext.rb:248
43
43
  msgid "Specific options:"
44
44
  msgstr ""
45
45
 
46
- #: ../lib/gettext/tools/msgfmt.rb:89 ../lib/gettext/tools/xgettext.rb:255
46
+ #: ../lib/gettext/tools/msgfmt.rb:89 ../lib/gettext/tools/xgettext.rb:251
47
47
  msgid "write output to specified file"
48
48
  msgstr ""
49
49
 
50
- #: ../lib/gettext/tools/msgfmt.rb:93 ../lib/gettext/tools/xgettext.rb:342
50
+ #: ../lib/gettext/tools/msgfmt.rb:93 ../lib/gettext/tools/xgettext.rb:349
51
51
  msgid "display version information and exit"
52
52
  msgstr ""
53
53
 
@@ -75,7 +75,7 @@ msgid ""
75
75
  " locale on your environment."
76
76
  msgstr ""
77
77
 
78
- #: ../lib/gettext/tools/msginit.rb:112 ../lib/gettext/tools/msgmerge.rb:317
78
+ #: ../lib/gettext/tools/msginit.rb:112 ../lib/gettext/tools/msgmerge.rb:374
79
79
  msgid "Display this help and exit"
80
80
  msgstr ""
81
81
 
@@ -109,11 +109,11 @@ msgstr ""
109
109
  msgid "Please enter your email address"
110
110
  msgstr ""
111
111
 
112
- #: ../lib/gettext/tools/msgmerge.rb:255
112
+ #: ../lib/gettext/tools/msgmerge.rb:308
113
113
  msgid "Usage: %s [OPTIONS] definition.po reference.pot"
114
114
  msgstr ""
115
115
 
116
- #: ../lib/gettext/tools/msgmerge.rb:258
116
+ #: ../lib/gettext/tools/msgmerge.rb:311
117
117
  msgid ""
118
118
  "Merges two Uniforum style .po files together. The definition.po file is an exi"
119
119
  "sting PO file with translations. The reference.pot file is the last created PO"
@@ -121,41 +121,49 @@ msgid ""
121
121
  "d by rxgettext."
122
122
  msgstr ""
123
123
 
124
- #: ../lib/gettext/tools/msgmerge.rb:269
124
+ #: ../lib/gettext/tools/msgmerge.rb:322
125
125
  msgid "Update definition.po"
126
126
  msgstr ""
127
127
 
128
- #: ../lib/gettext/tools/msgmerge.rb:274
128
+ #: ../lib/gettext/tools/msgmerge.rb:327
129
129
  msgid "Write output to specified file"
130
130
  msgstr ""
131
131
 
132
- #: ../lib/gettext/tools/msgmerge.rb:279 ../lib/gettext/tools/xgettext.rb:285
132
+ #: ../lib/gettext/tools/msgmerge.rb:332 ../lib/gettext/tools/xgettext.rb:292
133
133
  msgid "Generate sorted output"
134
134
  msgstr ""
135
135
 
136
- #: ../lib/gettext/tools/msgmerge.rb:284 ../lib/gettext/tools/xgettext.rb:290
136
+ #: ../lib/gettext/tools/msgmerge.rb:337 ../lib/gettext/tools/xgettext.rb:297
137
137
  msgid "Sort output by file location"
138
138
  msgstr ""
139
139
 
140
- #: ../lib/gettext/tools/msgmerge.rb:289 ../lib/gettext/tools/xgettext.rb:295
140
+ #: ../lib/gettext/tools/msgmerge.rb:342 ../lib/gettext/tools/xgettext.rb:302
141
141
  msgid "Sort output by msgid"
142
142
  msgstr ""
143
143
 
144
- #: ../lib/gettext/tools/msgmerge.rb:294 ../lib/gettext/tools/xgettext.rb:300
144
+ #: ../lib/gettext/tools/msgmerge.rb:347 ../lib/gettext/tools/xgettext.rb:307
145
145
  msgid "Preserve '#: FILENAME:LINE' lines"
146
146
  msgstr ""
147
147
 
148
- #: ../lib/gettext/tools/msgmerge.rb:299 ../lib/gettext/tools/xgettext.rb:305
148
+ #: ../lib/gettext/tools/msgmerge.rb:352 ../lib/gettext/tools/xgettext.rb:312
149
149
  msgid "Set output page width"
150
150
  msgstr ""
151
151
 
152
- #: ../lib/gettext/tools/msgmerge.rb:305 ../lib/gettext/tools/xgettext.rb:311
152
+ #: ../lib/gettext/tools/msgmerge.rb:358 ../lib/gettext/tools/xgettext.rb:318
153
153
  msgid ""
154
154
  "Break long message lines, longer than the output page width, into several line"
155
155
  "s"
156
156
  msgstr ""
157
157
 
158
- #: ../lib/gettext/tools/msgmerge.rb:323
158
+ #: ../lib/gettext/tools/msgmerge.rb:369
159
+ msgid "Disable fuzzy matching"
160
+ msgstr ""
161
+
162
+ #: ../lib/gettext/tools/msgmerge.rb:370
163
+ msgid "(enable)"
164
+ msgstr ""
165
+
166
+ #: ../lib/gettext/tools/msgmerge.rb:380
159
167
  msgid "Display version information and exit"
160
168
  msgstr ""
161
169
 
@@ -163,79 +171,83 @@ msgstr ""
163
171
  msgid "`%{file}' is not glade-2.0 format."
164
172
  msgstr ""
165
173
 
166
- #: ../lib/gettext/tools/xgettext.rb:64
174
+ #: ../lib/gettext/tools/xgettext.rb:65
167
175
  msgid "'%{klass}' is ignored."
168
176
  msgstr ""
169
177
 
170
- #: ../lib/gettext/tools/xgettext.rb:169
178
+ #: ../lib/gettext/tools/xgettext.rb:170
171
179
  msgid "Error parsing %{path}"
172
180
  msgstr ""
173
181
 
174
- #: ../lib/gettext/tools/xgettext.rb:228
182
+ #: ../lib/gettext/tools/xgettext.rb:229
175
183
  msgid "no input files"
176
184
  msgstr ""
177
185
 
178
- #: ../lib/gettext/tools/xgettext.rb:246
186
+ #: ../lib/gettext/tools/xgettext.rb:242
179
187
  msgid "Usage: %s input.rb [-r parser.rb] [-o output.pot]"
180
188
  msgstr ""
181
189
 
182
- #: ../lib/gettext/tools/xgettext.rb:249
190
+ #: ../lib/gettext/tools/xgettext.rb:245
183
191
  msgid "Extract translatable strings from given input files."
184
192
  msgstr ""
185
193
 
186
- #: ../lib/gettext/tools/xgettext.rb:260
194
+ #: ../lib/gettext/tools/xgettext.rb:256
187
195
  msgid "set package name in output"
188
196
  msgstr ""
189
197
 
190
- #: ../lib/gettext/tools/xgettext.rb:265
198
+ #: ../lib/gettext/tools/xgettext.rb:262
191
199
  msgid "set package version in output"
192
200
  msgstr ""
193
201
 
194
- #: ../lib/gettext/tools/xgettext.rb:270
195
- msgid "set report address for msgid bugs"
202
+ #: ../lib/gettext/tools/xgettext.rb:268
203
+ msgid "set report e-mail address for msgid bugs"
196
204
  msgstr ""
197
205
 
198
- #: ../lib/gettext/tools/xgettext.rb:275
206
+ #: ../lib/gettext/tools/xgettext.rb:274
199
207
  msgid "set copyright holder in output"
200
208
  msgstr ""
201
209
 
202
210
  #: ../lib/gettext/tools/xgettext.rb:280
211
+ msgid "set copyright year in output"
212
+ msgstr ""
213
+
214
+ #: ../lib/gettext/tools/xgettext.rb:286
203
215
  msgid "set encoding for output"
204
216
  msgstr ""
205
217
 
206
- #: ../lib/gettext/tools/xgettext.rb:322
218
+ #: ../lib/gettext/tools/xgettext.rb:329
207
219
  msgid "require the library before executing xgettext"
208
220
  msgstr ""
209
221
 
210
- #: ../lib/gettext/tools/xgettext.rb:327
222
+ #: ../lib/gettext/tools/xgettext.rb:334
211
223
  msgid ""
212
224
  "If TAG is specified, place comment blocks starting with TAG and precedding key"
213
225
  "word lines in output file"
214
226
  msgstr ""
215
227
 
216
- #: ../lib/gettext/tools/xgettext.rb:328
228
+ #: ../lib/gettext/tools/xgettext.rb:335
217
229
  msgid ""
218
230
  "If TAG is not specified, place all comment blocks preceing keyword lines in ou"
219
231
  "tput file"
220
232
  msgstr ""
221
233
 
222
- #: ../lib/gettext/tools/xgettext.rb:329
223
- msgid "no TAG"
234
+ #: ../lib/gettext/tools/xgettext.rb:336
235
+ msgid "(default: %s)"
224
236
  msgstr ""
225
237
 
226
- #: ../lib/gettext/tools/xgettext.rb:329
227
- msgid "(default: %s)"
238
+ #: ../lib/gettext/tools/xgettext.rb:336
239
+ msgid "no TAG"
228
240
  msgstr ""
229
241
 
230
- #: ../lib/gettext/tools/xgettext.rb:333
242
+ #: ../lib/gettext/tools/xgettext.rb:340
231
243
  msgid "run in debugging mode"
232
244
  msgstr ""
233
245
 
234
- #: ../lib/gettext/tools/xgettext.rb:337
246
+ #: ../lib/gettext/tools/xgettext.rb:344
235
247
  msgid "display this help and exit"
236
248
  msgstr ""
237
249
 
238
- #: ../lib/gettext/tools/xgettext.rb:368
250
+ #: ../lib/gettext/tools/xgettext.rb:375
239
251
  msgid ""
240
252
  "Warning: The empty \"\" msgid is reserved by gettext. So gettext(\"\") doesn't ret"
241
253
  "urns empty string but the header entry in po file."
@@ -25,7 +25,6 @@ require 'fixtures/simple'
25
25
  class TestLocalePath < Test::Unit::TestCase
26
26
  def setup
27
27
  GetText.locale = "ja_JP.eucJP"
28
- GetText::LocalePath.clear
29
28
  end
30
29
 
31
30
  def teardown
@@ -78,12 +77,10 @@ class TestLocalePath < Test::Unit::TestCase
78
77
  path1 = File.join(topdir, "locale")
79
78
  path2 = File.join(topdir, "cgi", "locale")
80
79
 
81
- GetText::LocalePath.memoize_clear
82
80
  ENV["GETTEXT_PATH"] = path1
83
81
  default_path_rules = GetText::LocalePath.default_path_rules
84
82
  assert_match(Regexp.compile(path1), default_path_rules[0])
85
83
 
86
- GetText::LocalePath.memoize_clear
87
84
  ENV["GETTEXT_PATH"] = "#{path1},#{path2}"
88
85
  default_path_rules = GetText::LocalePath.default_path_rules
89
86
  assert_match(Regexp.compile(path1), default_path_rules[0])
@@ -92,7 +89,6 @@ class TestLocalePath < Test::Unit::TestCase
92
89
 
93
90
  class TestDefaultPathRules < self
94
91
  def test_load_path_untached
95
- GetText::LocalePath.memoize_clear
96
92
  $LOAD_PATH.unshift("./lib")
97
93
  GetText::LocalePath.default_path_rules
98
94
  assert_equal($LOAD_PATH[0], "./lib")
@@ -274,23 +274,42 @@ EOE
274
274
  end
275
275
  end
276
276
 
277
- def test_obsolete_comment
278
- entry = GetText::POEntry.new(:normal)
279
- entry.msgid = :last
280
- obsolete_comment = <<-EOC
281
- # test.rb:10
282
- msgid "hello"
283
- msgstr "Salut"
284
- EOC
285
- entry.comment = obsolete_comment
277
+ class TestObsoleteComment < self
278
+ def test_obsolete_comment
279
+ comment = <<-COMMENT.chomp
280
+ #~ msgid "he"
281
+ #~ msgstr "il"
282
+ COMMENT
286
283
 
287
- expected_obsolete_comment = <<-EOC
288
- # test.rb:10
289
- #~ msgid "hello"
290
- #~ msgstr "Salut"
291
- EOC
284
+ assert_equal(<<-COMMENT, obsolete_entry(comment))
285
+ #~ msgid "he"
286
+ #~ msgstr "il"
287
+ COMMENT
288
+ end
289
+
290
+ def test_new_line_only
291
+ assert_equal("\n", obsolete_entry("\n"))
292
+ end
292
293
 
293
- assert_equal(expected_obsolete_comment, entry.to_s)
294
+ def test_no_comment_mark
295
+ comment = <<-COMMENT.chomp
296
+ msgid "he"
297
+ msgstr "il"
298
+ COMMENT
299
+
300
+ assert_equal(<<-COMMENT, obsolete_entry(comment))
301
+ #~ msgid "he"
302
+ #~ msgstr "il"
303
+ COMMENT
304
+ end
305
+
306
+ private
307
+ def obsolete_entry(comment)
308
+ entry = GetText::POEntry.new(:normal)
309
+ entry.msgid = :last
310
+ entry.comment = comment
311
+ entry.to_s
312
+ end
294
313
  end
295
314
 
296
315
  def test_translator_comment
@@ -398,6 +417,64 @@ msgstr ""
398
417
  end
399
418
  end
400
419
 
420
+ class TestPredicate < self
421
+ class TestHeader < self
422
+ def test_empty_msgid
423
+ entry = GetText::POEntry.new(:normal)
424
+ entry.msgid = ""
425
+ assert_true(entry.header?)
426
+ end
427
+
428
+ def test_not_empty_msgid
429
+ entry = GetText::POEntry.new(:normal)
430
+ entry.msgid = "hello"
431
+ assert_false(entry.header?)
432
+ end
433
+
434
+ def test_msgctxt
435
+ entry = GetText::POEntry.new(:msgctxt)
436
+ entry.msgid = ""
437
+ entry.msgctxt = "context"
438
+ assert_false(entry.header?)
439
+ end
440
+
441
+ def test_plural
442
+ entry = GetText::POEntry.new(:plural)
443
+ entry.msgid = ""
444
+ entry.msgid_plural = ""
445
+ assert_false(entry.header?)
446
+ end
447
+ end
448
+
449
+ class TestObsolete < self
450
+ def test_last_msgid
451
+ entry = GetText::POEntry.new(:normal)
452
+ entry.msgid = :last
453
+ assert_true(entry.obsolete?)
454
+ end
455
+
456
+ def test_not_lasty_msgid
457
+ entry = GetText::POEntry.new(:normal)
458
+ entry.msgid = "hello"
459
+ assert_false(entry.obsolete?)
460
+ end
461
+
462
+ def test_msgctxt
463
+ entry = GetText::POEntry.new(:msgctxt)
464
+ entry.msgid = :last
465
+ entry.msgctxt = "context"
466
+ assert_false(entry.obsolete?)
467
+ end
468
+
469
+ def test_plural
470
+ entry = GetText::POEntry.new(:plural)
471
+ entry.msgid = :last
472
+ entry.msgid_plural = ""
473
+ assert_false(entry.obsolete?)
474
+ end
475
+ end
476
+ end
477
+
401
478
  class TestFormatter < self
402
479
  class TestEscape < self
403
480
  def test_backslash
@@ -458,6 +535,15 @@ msgstr ""
458
535
  MESSAGE
459
536
  end
460
537
 
538
+ def test_multilines_disable_wrap
539
+ message = "long\nline\n"
540
+ assert_equal(<<-MESSAGE, format_message(message, :max_line_width => 0))
541
+ ""
542
+ "long\\n"
543
+ "line\\n"
544
+ MESSAGE
545
+ end
546
+
461
547
  private
462
548
  def format_message(message, options={})
463
549
  formatter = GetText::POEntry::Formatter.new(@entry, options)