gettext 3.4.6 → 3.4.8

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
  SHA256:
3
- metadata.gz: 623479874c1f5d1800b18fc285df714bdb8bc48b63f55547e634506ac89a5b4f
4
- data.tar.gz: b11c495203dc16e9668430a70f35ba93abe5126db80dbf04c773b72a609b34c8
3
+ metadata.gz: 935189b8e4a67d110df2c1e21b89bab5f70057772c31861d58c1d71935e4ace3
4
+ data.tar.gz: ee204b53fee909a7a23921a814fc3046312fe8fc6f3f576b7b883a2920896d02
5
5
  SHA512:
6
- metadata.gz: 9b6b842173b961104f45a2a5bc2dc6c1924d012aed19c114d748f8d85c94ae3510b4b7cf8db18a8df7790b19e57ab08b5ff2b7a5bc1ef50509f250a73cbcfce1
7
- data.tar.gz: 480d5730ff338bc4bb4a1045df02fd0adfeef8cdc468e1c53977751917a243172f7b97e58b363175fe0566658c04a4c27db8282f0afc4707e1daf091419c47b4
6
+ metadata.gz: a91c277a26e46db88ff1d67c85a2d0932a22cf0043d74cec373119dea8431614dfd35a2ddaef7ed18b557c07bdd27b60c3e8bf6fe79e7da80e42160f30883786
7
+ data.tar.gz: 00cd6a8ba2be7a06b9b9c7d5d8cc6e5f92bfbe768a32237dfcb029a105cd1b6508db88fb8988027c639d7bc385f43246d79513d5d4cc912d5e632ecbb5014c28
data/README.md CHANGED
@@ -244,11 +244,11 @@ n_(fruits, 3)
244
244
 
245
245
  ### Interpolating translations
246
246
 
247
- This is not a feature of gettext but worth noting. You can interpolate translated strings without the ruby String `%` operator.
247
+ This is not a feature of gettext but worth noting. You can interpolate translated strings with the ruby String `%` operator.
248
248
 
249
249
  ```ruby
250
250
  N_("active"); N_("inactive"); N_("paused") # possible value of status for parser to find.
251
- _("Your account is #{account_state}.") % { account_state: _(status) }
251
+ _("Your account is %{account_state}.") % { account_state: _(status) }
252
252
  ```
253
253
 
254
254
 
data/doc/text/news.md CHANGED
@@ -1,5 +1,49 @@
1
1
  # News
2
2
 
3
+ ## 3.4.8: 2023-10-22 {#version-3-4-8}
4
+
5
+ ### Fixes
6
+
7
+ * doc: Fixed a wrong description for interpolation.
8
+ * GH-102
9
+ * Patch by Ilmari Karonen
10
+
11
+ * po: Fixed a parser bug that flags aren't parsed correctly. If a
12
+ normal comment has "fuzzy", the entry is also treated as a fuzzy
13
+ entry.
14
+
15
+ * po: Fixed an output bug that flags aren't formatted correctly.
16
+ * GH-105
17
+ * Patch by Yoshikazu Nojima
18
+
19
+ ### Thanks
20
+
21
+ * Ilmari Karonen
22
+
23
+ * Yoshikazu Nojima
24
+
25
+ ## 3.4.7: 2023-08-17 {#version-3-4-7}
26
+
27
+ ### Fixes
28
+
29
+ * po: Fixed a parser bug that it may add a `fuzzy` flag to non-fuzzy
30
+ entry with `ignore_fuzzy: true`.
31
+
32
+ Example PO:
33
+
34
+ ```po
35
+ #, fuzzy
36
+ #: file.rb:10
37
+ msgid "hello"
38
+ msgstr "bonjour"
39
+
40
+ msgid "non-fuzzy"
41
+ msgstr "non-fuzzy string"
42
+ ```
43
+
44
+ `hello` entry is ignored because `ignore_fuzzy` is `true`. The
45
+ `fuzzy` flag in the `hello` entry is added to `non-fuzzy` entry.
46
+
3
47
  ## 3.4.6: 2023-07-12 {#version-3-4-6}
4
48
 
5
49
  ### Fixes
@@ -428,11 +428,12 @@ module GetText
428
428
  end
429
429
 
430
430
  def format_flag_comment
431
- formatted_flags = String.new
432
- @entry.flags.each do |flag|
433
- formatted_flags << format_comment(FLAG_MARK, flag)
431
+ if @entry.flags.empty?
432
+ String.new
433
+ else
434
+ joined_flags = @entry.flags.join(", ")
435
+ format_comment(FLAG_MARK, joined_flags)
434
436
  end
435
- formatted_flags
436
437
  end
437
438
 
438
439
  def format_previous_comment
@@ -19,7 +19,7 @@ require "gettext/po"
19
19
  module GetText
20
20
  class POParser < Racc::Parser
21
21
 
22
- module_eval(<<'...end po_parser.ry/module_eval...', 'po_parser.ry', 122)
22
+ module_eval(<<'...end po_parser.ry/module_eval...', 'po_parser.ry', 126)
23
23
  if GetText.respond_to?(:bindtextdomain)
24
24
  include GetText
25
25
  GetText.bindtextdomain("gettext")
@@ -62,16 +62,8 @@ module_eval(<<'...end po_parser.ry/module_eval...', 'po_parser.ry', 122)
62
62
  private :unescape
63
63
 
64
64
  def parse(str, data)
65
- @translator_comments = []
66
- @extracted_comments = []
67
- @references = []
68
- @flags = []
69
- @previous = []
70
- @comments = []
65
+ clear
71
66
  @data = data
72
- @fuzzy = false
73
- @msgctxt = nil
74
- @msgid_plural = nil
75
67
 
76
68
  str = str.strip
77
69
  @q = []
@@ -157,15 +149,7 @@ module_eval(<<'...end po_parser.ry/module_eval...', 'po_parser.ry', 122)
157
149
  @data.set_comment(msgid, format_comment(@comments))
158
150
  end
159
151
 
160
- @translator_comments = []
161
- @extracted_comments = []
162
- @references = []
163
- @flags = []
164
- @previous = []
165
- @references = []
166
- @comments.clear
167
- @msgctxt = nil
168
- @msgid_plural = nil
152
+ clear
169
153
  end
170
154
 
171
155
  def format_comment(comments)
@@ -177,7 +161,11 @@ module_eval(<<'...end po_parser.ry/module_eval...', 'po_parser.ry', 122)
177
161
  end
178
162
 
179
163
  def on_comment(comment)
180
- @fuzzy = true if (/fuzzy/ =~ comment)
164
+ if comment.start_with?(POFormat::FLAG_MARK)
165
+ content = comment[POFormat::FLAG_MARK.size..-1]
166
+ flags = parse_flags_line(content)
167
+ @fuzzy = true if flags.include?("fuzzy")
168
+ end
181
169
  if @data.instance_of?(PO)
182
170
  if comment == "#"
183
171
  @translator_comments << ""
@@ -192,7 +180,7 @@ module_eval(<<'...end po_parser.ry/module_eval...', 'po_parser.ry', 122)
192
180
  when POFormat::REFERENCE_COMMENT_MARK
193
181
  @references.concat(parse_references_line(content))
194
182
  when POFormat::FLAG_MARK
195
- @flags.concat(parse_flags_line(content))
183
+ @flags.concat(flags)
196
184
  when POFormat::PREVIOUS_COMMENT_MARK
197
185
  @previous << content
198
186
  else
@@ -261,7 +249,19 @@ module_eval(<<'...end po_parser.ry/module_eval...', 'po_parser.ry', 122)
261
249
  end
262
250
 
263
251
  def parse_flags_line(line)
264
- line.split(/\s+/)
252
+ line.split(",").collect(&:strip)
253
+ end
254
+
255
+ def clear
256
+ @translator_comments = []
257
+ @extracted_comments = []
258
+ @references = []
259
+ @flags = []
260
+ @previous = []
261
+ @references = []
262
+ @comments = []
263
+ @msgctxt = nil
264
+ @msgid_plural = nil
265
265
  end
266
266
  ...end po_parser.ry/module_eval...
267
267
  ##### State transition tables begin ###
@@ -417,14 +417,18 @@ module_eval(<<'.,.,', 'po_parser.ry', 38)
417
417
  end
418
418
  end
419
419
  @fuzzy = false
420
- on_message(msgid, msgstr) if use_message_p
420
+ if use_message_p
421
+ on_message(msgid, msgstr)
422
+ else
423
+ clear
424
+ end
421
425
  result = ""
422
426
 
423
427
  result
424
428
  end
425
429
  .,.,
426
430
 
427
- module_eval(<<'.,.,', 'po_parser.ry', 60)
431
+ module_eval(<<'.,.,', 'po_parser.ry', 64)
428
432
  def _reduce_9(val, _values, result)
429
433
  if @fuzzy and ignore_fuzzy?
430
434
  if val[1] != ""
@@ -446,7 +450,7 @@ module_eval(<<'.,.,', 'po_parser.ry', 60)
446
450
  end
447
451
  .,.,
448
452
 
449
- module_eval(<<'.,.,', 'po_parser.ry', 81)
453
+ module_eval(<<'.,.,', 'po_parser.ry', 85)
450
454
  def _reduce_10(val, _values, result)
451
455
  if val[0].size > 0
452
456
  result = val[0] + "\000" + val[1]
@@ -460,7 +464,7 @@ module_eval(<<'.,.,', 'po_parser.ry', 81)
460
464
 
461
465
  # reduce 11 omitted
462
466
 
463
- module_eval(<<'.,.,', 'po_parser.ry', 93)
467
+ module_eval(<<'.,.,', 'po_parser.ry', 97)
464
468
  def _reduce_12(val, _values, result)
465
469
  result = val[2]
466
470
 
@@ -468,7 +472,7 @@ module_eval(<<'.,.,', 'po_parser.ry', 93)
468
472
  end
469
473
  .,.,
470
474
 
471
- module_eval(<<'.,.,', 'po_parser.ry', 100)
475
+ module_eval(<<'.,.,', 'po_parser.ry', 104)
472
476
  def _reduce_13(val, _values, result)
473
477
  on_comment(val[0])
474
478
 
@@ -476,7 +480,7 @@ module_eval(<<'.,.,', 'po_parser.ry', 100)
476
480
  end
477
481
  .,.,
478
482
 
479
- module_eval(<<'.,.,', 'po_parser.ry', 108)
483
+ module_eval(<<'.,.,', 'po_parser.ry', 112)
480
484
  def _reduce_14(val, _values, result)
481
485
  result = val.delete_if{|item| item == ""}.join
482
486
 
@@ -484,7 +488,7 @@ module_eval(<<'.,.,', 'po_parser.ry', 108)
484
488
  end
485
489
  .,.,
486
490
 
487
- module_eval(<<'.,.,', 'po_parser.ry', 112)
491
+ module_eval(<<'.,.,', 'po_parser.ry', 116)
488
492
  def _reduce_15(val, _values, result)
489
493
  result = val[0]
490
494
 
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
2
- #
3
- # Copyright (C) 2012-2014 Kouhei Sutou <kou@clear-code.com>
1
+ # Copyright (C) 2012-2023 Sutou Kouhei <kou@clear-code.com>
4
2
  #
5
3
  # License: Ruby's or LGPL
6
4
  #
@@ -452,8 +450,8 @@ module GetText
452
450
  locale = args.locale || ENV["LOCALE"]
453
451
  if locale.nil?
454
452
  raise "specify locale name by " +
455
- "'rake #{_task.name}[${LOCALE}]' or " +
456
- "rake #{_task.name} LOCALE=${LOCALE}'"
453
+ "rake '#{_task.name}[${LOCALE}]' or " +
454
+ "rake #{_task.name} LOCALE=${LOCALE}'"
457
455
  end
458
456
  define_edit_po_file_task(locale)
459
457
  define_po_file_task(locale)
@@ -1,13 +1,13 @@
1
1
  =begin
2
2
  version - version information of gettext
3
3
 
4
- Copyright (C) 2012-2023 Sutou Kouhei <kou@clear-code.com>
5
- Copyright (C) 2005-2009 Masao Mutoh
4
+ Copyright (C) 2012-2023 Sutou Kouhei <kou@clear-code.com>
5
+ Copyright (C) 2005-2009 Masao Mutoh
6
6
 
7
7
  You may redistribute it and/or modify it under the same
8
8
  license terms as Ruby or LGPL.
9
9
  =end
10
10
 
11
11
  module GetText
12
- VERSION = "3.4.6"
12
+ VERSION = "3.4.8"
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.4.6\n"
9
+ "Project-Id-Version: gettext 3.4.8\n"
10
10
  "Report-Msgid-Bugs-To: \n"
11
- "POT-Creation-Date: 2023-07-12 10:23+0900\n"
12
- "PO-Revision-Date: 2023-07-12 10:23+0900\n"
11
+ "POT-Creation-Date: 2023-10-22 06:20+0900\n"
12
+ "PO-Revision-Date: 2023-10-22 06:20+0900\n"
13
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
15
15
  "Language: \n"
data/src/po_parser.ry CHANGED
@@ -2,9 +2,9 @@
2
2
  #
3
3
  # po_parser.ry - ruby version of msgfmt
4
4
  #
5
- # Copyright (C) 2002-2008 Masao Mutoh <mutomasa at gmail.com>
6
- # Copyright (C) 2012-2017 Kouhei Sutou <kou@clear-code.com>
7
- # Copyright (C) 2012-2013 Haruka Yoshihara <yoshihara@clear-code.com>
5
+ # Copyright (C) 2002-2008 Masao Mutoh <mutomasa at gmail.com>
6
+ # Copyright (C) 2012-2023 Sutou Kouhei <kou@clear-code.com>
7
+ # Copyright (C) 2012-2013 Haruka Yoshihara <yoshihara@clear-code.com>
8
8
  #
9
9
  # You may redistribute it and/or modify it under the same
10
10
  # license terms as Ruby or LGPL.
@@ -51,7 +51,11 @@ class GetText::POParser
51
51
  end
52
52
  end
53
53
  @fuzzy = false
54
- on_message(msgid, msgstr) if use_message_p
54
+ if use_message_p
55
+ on_message(msgid, msgstr)
56
+ else
57
+ clear
58
+ end
55
59
  result = ""
56
60
  }
57
61
 
@@ -161,16 +165,8 @@ require "gettext/po"
161
165
  private :unescape
162
166
 
163
167
  def parse(str, data)
164
- @translator_comments = []
165
- @extracted_comments = []
166
- @references = []
167
- @flags = []
168
- @previous = []
169
- @comments = []
168
+ clear
170
169
  @data = data
171
- @fuzzy = false
172
- @msgctxt = nil
173
- @msgid_plural = nil
174
170
 
175
171
  str = str.strip
176
172
  @q = []
@@ -256,15 +252,7 @@ require "gettext/po"
256
252
  @data.set_comment(msgid, format_comment(@comments))
257
253
  end
258
254
 
259
- @translator_comments = []
260
- @extracted_comments = []
261
- @references = []
262
- @flags = []
263
- @previous = []
264
- @references = []
265
- @comments.clear
266
- @msgctxt = nil
267
- @msgid_plural = nil
255
+ clear
268
256
  end
269
257
 
270
258
  def format_comment(comments)
@@ -276,7 +264,11 @@ require "gettext/po"
276
264
  end
277
265
 
278
266
  def on_comment(comment)
279
- @fuzzy = true if (/fuzzy/ =~ comment)
267
+ if comment.start_with?(POFormat::FLAG_MARK)
268
+ content = comment[POFormat::FLAG_MARK.size..-1]
269
+ flags = parse_flags_line(content)
270
+ @fuzzy = flags.include?("fuzzy")
271
+ end
280
272
  if @data.instance_of?(PO)
281
273
  if comment == "#"
282
274
  @translator_comments << ""
@@ -291,7 +283,7 @@ require "gettext/po"
291
283
  when POFormat::REFERENCE_COMMENT_MARK
292
284
  @references.concat(parse_references_line(content))
293
285
  when POFormat::FLAG_MARK
294
- @flags.concat(parse_flags_line(content))
286
+ @flags.concat(flags)
295
287
  when POFormat::PREVIOUS_COMMENT_MARK
296
288
  @previous << content
297
289
  else
@@ -360,7 +352,19 @@ require "gettext/po"
360
352
  end
361
353
 
362
354
  def parse_flags_line(line)
363
- line.split(/\s+/)
355
+ line.split(",").collect(&:strip)
356
+ end
357
+
358
+ def clear
359
+ @translator_comments = []
360
+ @extracted_comments = []
361
+ @references = []
362
+ @flags = []
363
+ @previous = []
364
+ @references = []
365
+ @comments = []
366
+ @msgctxt = nil
367
+ @msgid_plural = nil
364
368
  end
365
369
  ---- footer
366
370
 
@@ -344,6 +344,20 @@ EOP
344
344
  assert_equal(expected_po, entry.to_s)
345
345
  end
346
346
 
347
+ def test_multiple_flags
348
+ entry = GetText::POEntry.new(:normal)
349
+ entry.msgid = "msgid"
350
+ entry.msgstr = "msgstr"
351
+ entry.flags = ["It's the flag.", "fuzzy"]
352
+
353
+ expected_po = <<-EOP
354
+ #, It's the flag., fuzzy
355
+ msgid "msgid"
356
+ msgstr "msgstr"
357
+ EOP
358
+ assert_equal(expected_po, entry.to_s)
359
+ end
360
+
347
361
  def test_previous
348
362
  entry = GetText::POEntry.new(:normal)
349
363
  entry.msgid = "msgid"
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2012-2020 Sutou Kouhei <kou@clear-code.com>
1
+ # Copyright (C) 2012-2023 Sutou Kouhei <kou@clear-code.com>
2
2
  # Copyright (C) 2012 Haruka Yoshihara <yoshihara@clear-code.com>
3
3
  #
4
4
  # License: Ruby's or LGPL
@@ -238,6 +238,39 @@ EOP
238
238
  assert_equal("fuzzy", entries["hello"].flag)
239
239
  end
240
240
 
241
+ def test_fuzzy_ignore
242
+ po_file = create_po_file(<<-PO)
243
+ #, fuzzy
244
+ #: file.rb:10
245
+ msgid "hello"
246
+ msgstr "bonjour"
247
+
248
+ #, c-format, fuzzy , no-sh-format
249
+ #: file.rb:11
250
+ msgid "world"
251
+ msgstr "monde"
252
+
253
+ # This is not fuzzy
254
+ msgid "non-fuzzy"
255
+ msgstr "non-fuzzy string"
256
+ PO
257
+ entries = suppress_warning do
258
+ parse_po_file(po_file)
259
+ end
260
+
261
+ actual = entries.collect do |entry|
262
+ [
263
+ entry.msgid,
264
+ entry.msgstr,
265
+ entry.flags,
266
+ ]
267
+ end
268
+ assert_equal([
269
+ ["non-fuzzy", "non-fuzzy string", []],
270
+ ],
271
+ actual)
272
+ end
273
+
241
274
  private
242
275
  def parse_po_file(po_file, options={:ignore_fuzzy => true})
243
276
  ignore_fuzzy = options[:ignore_fuzzy]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gettext
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.6
4
+ version: 3.4.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-07-12 00:00:00.000000000 Z
12
+ date: 2023-10-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: erubi