gettext 3.4.4 → 3.4.7

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: '08ec1d309ee833a5038abf2d2e442006d05be64ac85d270a5ebc0f975049e156'
4
- data.tar.gz: ab50d773df116c00aa0b02ef6d13dfb5f375e481cbaafef29a6415c9892f4949
3
+ metadata.gz: fa1902916e0f5d7d7e6f55abac75be8b7766b42ce209b7a1a166e146554994ba
4
+ data.tar.gz: 295926d043977eb7001e89215848f16d527e6141e0d7c23d29db147d635b732a
5
5
  SHA512:
6
- metadata.gz: '0590096a216d72fc22176eab9b266c8acecce48375dc123f53cdc64f606d4310061f2d794ad011daaab5574e3f70654580e6c085f3d865eaa4f7acd9fd283636'
7
- data.tar.gz: 31d4038bdd98dfbb04c7d62c31099645cdd053341a1b2ef532cf46473352de8278aef615d47ca8c23d00047479a578a8c47e42715c2788ece1d0b52f8c235e36
6
+ metadata.gz: 79cdda51880bc12d8d3c02bfcf07a8776f0dc18e6b3ee8daa5e3654786cc0fc4116c0d839f36a6cb7803b927e0f34cc37de32b447e906e11575f668dcf06a371
7
+ data.tar.gz: ca5da85ee4a5fe13032229c95d41e8d12d258e2809f85a3cd268a8e4b7752c637b764d5a0d6bec466ceb68ba09005fb026815fff884178b5900bbdd64aa3329e
data/doc/text/news.md CHANGED
@@ -1,5 +1,40 @@
1
1
  # News
2
2
 
3
+ ## 3.4.7: 2023-08-17 {#version-3-4-7}
4
+
5
+ ### Fixes
6
+
7
+ * po: Fixed a parser bug that it may add a `fuzzy` flag to non-fuzzy
8
+ entry with `ignore_fuzzy: true`.
9
+
10
+ Example PO:
11
+
12
+ ```po
13
+ #, fuzzy
14
+ #: file.rb:10
15
+ msgid "hello"
16
+ msgstr "bonjour"
17
+
18
+ msgid "non-fuzzy"
19
+ msgstr "non-fuzzy string"
20
+ ```
21
+
22
+ `hello` entry is ignored because `ignore_fuzzy` is `true`. The
23
+ `fuzzy` flag in the `hello` entry is added to `non-fuzzy` entry.
24
+
25
+ ## 3.4.6: 2023-07-12 {#version-3-4-6}
26
+
27
+ ### Fixes
28
+
29
+ * po: Fixed a bug that parsed `msgid`/`msgstr`/`msgctxt` in `.po`
30
+ may be too much unescaped.
31
+
32
+ ## 3.4.5: 2023-07-12 {#version-3-4-5}
33
+
34
+ ### Improvements
35
+
36
+ * po: Added support for escaping `\r` in `msgid`/`msgstr`.
37
+
3
38
  ## 3.4.4: 2023-06-11 {#version-3-4-4}
4
39
 
5
40
  ### Improvements
@@ -241,11 +241,12 @@ module GetText
241
241
  def escape(string)
242
242
  return "" if string.nil?
243
243
 
244
- string.gsub(/([\\"\t\n])/) do
245
- special_character = $1
244
+ string.gsub(/[\\"\t\r\n]/) do |special_character|
246
245
  case special_character
247
246
  when "\t"
248
247
  "\\t"
248
+ when "\r"
249
+ "\\r"
249
250
  when "\n"
250
251
  "\\n"
251
252
  else
@@ -8,7 +8,7 @@
8
8
 
9
9
  #
10
10
  # DO NOT MODIFY!!!!
11
- # This file is automatically generated by Racc 1.7.0
11
+ # This file is automatically generated by Racc 1.7.1
12
12
  # from Racc grammar file "".
13
13
  #
14
14
 
@@ -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', 123)
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")
@@ -44,31 +44,26 @@ module_eval(<<'...end po_parser.ry/module_eval...', 'po_parser.ry', 123)
44
44
  @report_warning
45
45
  end
46
46
 
47
- def unescape(orig)
48
- ret = orig.gsub(/\\n/, "\n")
49
- ret.gsub!(/\\t/, "\t")
50
- ret.gsub!(/\\r/, "\r")
51
- ret.gsub!(/\\"/, "\"")
52
- ret
47
+ def unescape(string)
48
+ string.gsub(/\\(.)/) do
49
+ escaped_character = $1
50
+ case escaped_character
51
+ when "t"
52
+ "\t"
53
+ when "r"
54
+ "\r"
55
+ when "n"
56
+ "\n"
57
+ else
58
+ escaped_character
59
+ end
60
+ end
53
61
  end
54
62
  private :unescape
55
63
 
56
- def unescape_string(string)
57
- string.gsub(/\\\\/, "\\")
58
- end
59
- private :unescape_string
60
-
61
64
  def parse(str, data)
62
- @translator_comments = []
63
- @extracted_comments = []
64
- @references = []
65
- @flags = []
66
- @previous = []
67
- @comments = []
65
+ clear
68
66
  @data = data
69
- @fuzzy = false
70
- @msgctxt = nil
71
- @msgid_plural = nil
72
67
 
73
68
  str = str.strip
74
69
  @q = []
@@ -102,7 +97,7 @@ module_eval(<<'...end po_parser.ry/module_eval...', 'po_parser.ry', 123)
102
97
  @q.push [:COMMENT, $&]
103
98
  str = $'
104
99
  when /\A\"(.*)\"/
105
- @q.push [:STRING, unescape_string($1)]
100
+ @q.push [:STRING, unescape($1)]
106
101
  str = $'
107
102
  else
108
103
  #c = str[0,1]
@@ -154,15 +149,7 @@ module_eval(<<'...end po_parser.ry/module_eval...', 'po_parser.ry', 123)
154
149
  @data.set_comment(msgid, format_comment(@comments))
155
150
  end
156
151
 
157
- @translator_comments = []
158
- @extracted_comments = []
159
- @references = []
160
- @flags = []
161
- @previous = []
162
- @references = []
163
- @comments.clear
164
- @msgctxt = nil
165
- @msgid_plural = nil
152
+ clear
166
153
  end
167
154
 
168
155
  def format_comment(comments)
@@ -260,6 +247,18 @@ module_eval(<<'...end po_parser.ry/module_eval...', 'po_parser.ry', 123)
260
247
  def parse_flags_line(line)
261
248
  line.split(/\s+/)
262
249
  end
250
+
251
+ def clear
252
+ @translator_comments = []
253
+ @extracted_comments = []
254
+ @references = []
255
+ @flags = []
256
+ @previous = []
257
+ @references = []
258
+ @comments = []
259
+ @msgctxt = nil
260
+ @msgid_plural = nil
261
+ end
263
262
  ...end po_parser.ry/module_eval...
264
263
  ##### State transition tables begin ###
265
264
 
@@ -387,7 +386,7 @@ Racc_debug_parser = true
387
386
 
388
387
  module_eval(<<'.,.,', 'po_parser.ry', 26)
389
388
  def _reduce_5(val, _values, result)
390
- @msgctxt = unescape(val[1])
389
+ @msgctxt = val[1]
391
390
 
392
391
  result
393
392
  end
@@ -399,9 +398,8 @@ module_eval(<<'.,.,', 'po_parser.ry', 26)
399
398
 
400
399
  module_eval(<<'.,.,', 'po_parser.ry', 38)
401
400
  def _reduce_8(val, _values, result)
402
- msgid_raw = val[1]
403
- msgid = unescape(msgid_raw)
404
- msgstr = unescape(val[3])
401
+ msgid = val[1]
402
+ msgstr = val[3]
405
403
  use_message_p = true
406
404
  if @fuzzy and not msgid.empty?
407
405
  use_message_p = (not ignore_fuzzy?)
@@ -411,18 +409,22 @@ module_eval(<<'.,.,', 'po_parser.ry', 38)
411
409
  else
412
410
  $stderr.print _("Warning: fuzzy message was used.\n")
413
411
  end
414
- $stderr.print " #{@po_file}: msgid '#{msgid_raw}'\n"
412
+ $stderr.print " #{@po_file}: msgid '#{msgid}'\n"
415
413
  end
416
414
  end
417
415
  @fuzzy = false
418
- on_message(msgid, msgstr) if use_message_p
416
+ if use_message_p
417
+ on_message(msgid, msgstr)
418
+ else
419
+ clear
420
+ end
419
421
  result = ""
420
422
 
421
423
  result
422
424
  end
423
425
  .,.,
424
426
 
425
- module_eval(<<'.,.,', 'po_parser.ry', 61)
427
+ module_eval(<<'.,.,', 'po_parser.ry', 64)
426
428
  def _reduce_9(val, _values, result)
427
429
  if @fuzzy and ignore_fuzzy?
428
430
  if val[1] != ""
@@ -444,7 +446,7 @@ module_eval(<<'.,.,', 'po_parser.ry', 61)
444
446
  end
445
447
  .,.,
446
448
 
447
- module_eval(<<'.,.,', 'po_parser.ry', 82)
449
+ module_eval(<<'.,.,', 'po_parser.ry', 85)
448
450
  def _reduce_10(val, _values, result)
449
451
  if val[0].size > 0
450
452
  result = val[0] + "\000" + val[1]
@@ -458,7 +460,7 @@ module_eval(<<'.,.,', 'po_parser.ry', 82)
458
460
 
459
461
  # reduce 11 omitted
460
462
 
461
- module_eval(<<'.,.,', 'po_parser.ry', 94)
463
+ module_eval(<<'.,.,', 'po_parser.ry', 97)
462
464
  def _reduce_12(val, _values, result)
463
465
  result = val[2]
464
466
 
@@ -466,7 +468,7 @@ module_eval(<<'.,.,', 'po_parser.ry', 94)
466
468
  end
467
469
  .,.,
468
470
 
469
- module_eval(<<'.,.,', 'po_parser.ry', 101)
471
+ module_eval(<<'.,.,', 'po_parser.ry', 104)
470
472
  def _reduce_13(val, _values, result)
471
473
  on_comment(val[0])
472
474
 
@@ -474,7 +476,7 @@ module_eval(<<'.,.,', 'po_parser.ry', 101)
474
476
  end
475
477
  .,.,
476
478
 
477
- module_eval(<<'.,.,', 'po_parser.ry', 109)
479
+ module_eval(<<'.,.,', 'po_parser.ry', 112)
478
480
  def _reduce_14(val, _values, result)
479
481
  result = val.delete_if{|item| item == ""}.join
480
482
 
@@ -482,7 +484,7 @@ module_eval(<<'.,.,', 'po_parser.ry', 109)
482
484
  end
483
485
  .,.,
484
486
 
485
- module_eval(<<'.,.,', 'po_parser.ry', 113)
487
+ module_eval(<<'.,.,', 'po_parser.ry', 116)
486
488
  def _reduce_15(val, _values, result)
487
489
  result = val[0]
488
490
 
@@ -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,7 +1,7 @@
1
1
  =begin
2
2
  version - version information of gettext
3
3
 
4
- Copyright (C) 2012-2022 Sutou Kouhei <kou@clear-code.com>
4
+ Copyright (C) 2012-2023 Sutou Kouhei <kou@clear-code.com>
5
5
  Copyright (C) 2005-2009 Masao Mutoh
6
6
 
7
7
  You may redistribute it and/or modify it under the same
@@ -9,5 +9,5 @@
9
9
  =end
10
10
 
11
11
  module GetText
12
- VERSION = "3.4.4"
12
+ VERSION = "3.4.7"
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.4\n"
9
+ "Project-Id-Version: gettext 3.4.7\n"
10
10
  "Report-Msgid-Bugs-To: \n"
11
- "POT-Creation-Date: 2023-06-11 06:21+0900\n"
12
- "PO-Revision-Date: 2023-06-11 06:21+0900\n"
11
+ "POT-Creation-Date: 2023-08-17 17:02+0900\n"
12
+ "PO-Revision-Date: 2023-08-17 17:02+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.
@@ -24,7 +24,7 @@ class GetText::POParser
24
24
  msgctxt
25
25
  : MSGCTXT string_list
26
26
  {
27
- @msgctxt = unescape(val[1])
27
+ @msgctxt = val[1]
28
28
  }
29
29
  ;
30
30
 
@@ -36,9 +36,8 @@ class GetText::POParser
36
36
  single_message
37
37
  : MSGID string_list MSGSTR string_list
38
38
  {
39
- msgid_raw = val[1]
40
- msgid = unescape(msgid_raw)
41
- msgstr = unescape(val[3])
39
+ msgid = val[1]
40
+ msgstr = val[3]
42
41
  use_message_p = true
43
42
  if @fuzzy and not msgid.empty?
44
43
  use_message_p = (not ignore_fuzzy?)
@@ -48,11 +47,15 @@ class GetText::POParser
48
47
  else
49
48
  $stderr.print _("Warning: fuzzy message was used.\n")
50
49
  end
51
- $stderr.print " #{@po_file}: msgid '#{msgid_raw}'\n"
50
+ $stderr.print " #{@po_file}: msgid '#{msgid}'\n"
52
51
  end
53
52
  end
54
53
  @fuzzy = false
55
- on_message(msgid, msgstr) if use_message_p
54
+ if use_message_p
55
+ on_message(msgid, msgstr)
56
+ else
57
+ clear
58
+ end
56
59
  result = ""
57
60
  }
58
61
 
@@ -144,31 +147,26 @@ require "gettext/po"
144
147
  @report_warning
145
148
  end
146
149
 
147
- def unescape(orig)
148
- ret = orig.gsub(/\\n/, "\n")
149
- ret.gsub!(/\\t/, "\t")
150
- ret.gsub!(/\\r/, "\r")
151
- ret.gsub!(/\\"/, "\"")
152
- ret
150
+ def unescape(string)
151
+ string.gsub(/\\(.)/) do
152
+ escaped_character = $1
153
+ case escaped_character
154
+ when "t"
155
+ "\t"
156
+ when "r"
157
+ "\r"
158
+ when "n"
159
+ "\n"
160
+ else
161
+ escaped_character
162
+ end
163
+ end
153
164
  end
154
165
  private :unescape
155
166
 
156
- def unescape_string(string)
157
- string.gsub(/\\\\/, "\\")
158
- end
159
- private :unescape_string
160
-
161
167
  def parse(str, data)
162
- @translator_comments = []
163
- @extracted_comments = []
164
- @references = []
165
- @flags = []
166
- @previous = []
167
- @comments = []
168
+ clear
168
169
  @data = data
169
- @fuzzy = false
170
- @msgctxt = nil
171
- @msgid_plural = nil
172
170
 
173
171
  str = str.strip
174
172
  @q = []
@@ -202,7 +200,7 @@ require "gettext/po"
202
200
  @q.push [:COMMENT, $&]
203
201
  str = $'
204
202
  when /\A\"(.*)\"/
205
- @q.push [:STRING, unescape_string($1)]
203
+ @q.push [:STRING, unescape($1)]
206
204
  str = $'
207
205
  else
208
206
  #c = str[0,1]
@@ -254,15 +252,7 @@ require "gettext/po"
254
252
  @data.set_comment(msgid, format_comment(@comments))
255
253
  end
256
254
 
257
- @translator_comments = []
258
- @extracted_comments = []
259
- @references = []
260
- @flags = []
261
- @previous = []
262
- @references = []
263
- @comments.clear
264
- @msgctxt = nil
265
- @msgid_plural = nil
255
+ clear
266
256
  end
267
257
 
268
258
  def format_comment(comments)
@@ -360,5 +350,17 @@ require "gettext/po"
360
350
  def parse_flags_line(line)
361
351
  line.split(/\s+/)
362
352
  end
353
+
354
+ def clear
355
+ @translator_comments = []
356
+ @extracted_comments = []
357
+ @references = []
358
+ @flags = []
359
+ @previous = []
360
+ @references = []
361
+ @comments = []
362
+ @msgctxt = nil
363
+ @msgid_plural = nil
364
+ end
363
365
  ---- footer
364
366
 
@@ -233,13 +233,15 @@ EOE
233
233
  class TestEscape < self
234
234
  def test_normal
235
235
  entry = GetText::POEntry.new(:normal)
236
- entry.msgid = "He said \"hello.\""
237
- entry.msgstr = "Il a dit \"bonjour.\""
236
+ entry.msgid = "He said \"hello.\"\r\n"
237
+ entry.msgstr = "Il a dit \"bonjour.\"\r\n"
238
238
  entry.references = ["file1:1", "file2:10"]
239
239
  expected_po = <<-EOE
240
240
  #: file1:1 file2:10
241
- msgid "He said \\"hello.\\""
242
- msgstr "Il a dit \\"bonjour.\\""
241
+ msgid ""
242
+ "He said \\"hello.\\"\\r\\n"
243
+ msgstr ""
244
+ "Il a dit \\"bonjour.\\"\\r\\n"
243
245
  EOE
244
246
  assert_equal(expected_po, entry.to_s)
245
247
  end
@@ -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
@@ -62,6 +62,16 @@ EOP
62
62
  class TestPO < self
63
63
  include Helper::Warning
64
64
 
65
+ def test_msgid_escape
66
+ po_file = create_po_file(<<-'EOP')
67
+ msgid "\\\\r \\r \t \r \n"
68
+ msgstr "\\\\r \\r \t \r \n"
69
+ EOP
70
+ entries = parse_po_file(po_file)
71
+ assert_equal("\\\\r \\r \t \r \n",
72
+ entries["\\\\r \\r \t \r \n"].msgstr)
73
+ end
74
+
65
75
  def test_msgstr
66
76
  po_file = create_po_file(<<-EOP)
67
77
  # This is the comment.
@@ -228,6 +238,33 @@ EOP
228
238
  assert_equal("fuzzy", entries["hello"].flag)
229
239
  end
230
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
+ msgid "non-fuzzy"
249
+ msgstr "non-fuzzy string"
250
+ PO
251
+ entries = suppress_warning do
252
+ parse_po_file(po_file)
253
+ end
254
+
255
+ actual = entries.collect do |entry|
256
+ [
257
+ entry.msgid,
258
+ entry.msgstr,
259
+ entry.flags,
260
+ ]
261
+ end
262
+ assert_equal([
263
+ ["non-fuzzy", "non-fuzzy string", []],
264
+ ],
265
+ actual)
266
+ end
267
+
231
268
  private
232
269
  def parse_po_file(po_file, options={:ignore_fuzzy => true})
233
270
  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.4
4
+ version: 3.4.7
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-06-10 00:00:00.000000000 Z
12
+ date: 2023-08-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: erubi