gettext 3.3.2 → 3.3.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/doc/text/news.md +217 -0
  3. data/gettext.gemspec +0 -1
  4. data/lib/gettext/locale_path.rb +12 -8
  5. data/lib/gettext/tools/msgmerge.rb +13 -0
  6. data/lib/gettext/tools/parser/erb.rb +9 -1
  7. data/lib/gettext/tools/parser/gtk_builder_ui_definitions.rb +0 -3
  8. data/lib/gettext/tools/parser/ruby.rb +50 -23
  9. data/lib/gettext/version.rb +1 -1
  10. data/po/bg/gettext.edit.po +33 -25
  11. data/po/bg/gettext.po +9 -3
  12. data/po/bs/gettext.edit.po +33 -25
  13. data/po/bs/gettext.po +9 -3
  14. data/po/ca/gettext.edit.po +33 -25
  15. data/po/ca/gettext.po +9 -3
  16. data/po/cs/gettext.edit.po +33 -25
  17. data/po/cs/gettext.po +9 -3
  18. data/po/de/gettext.edit.po +33 -25
  19. data/po/de/gettext.po +9 -3
  20. data/po/el/gettext.edit.po +33 -25
  21. data/po/el/gettext.po +9 -3
  22. data/po/eo/gettext.edit.po +33 -25
  23. data/po/eo/gettext.po +9 -3
  24. data/po/es/gettext.edit.po +33 -25
  25. data/po/es/gettext.po +9 -3
  26. data/po/et/gettext.edit.po +33 -25
  27. data/po/et/gettext.po +9 -3
  28. data/po/fr/gettext.edit.po +33 -25
  29. data/po/fr/gettext.po +9 -3
  30. data/po/gettext.pot +36 -28
  31. data/po/hr/gettext.edit.po +33 -25
  32. data/po/hr/gettext.po +9 -3
  33. data/po/hu/gettext.edit.po +33 -25
  34. data/po/hu/gettext.po +9 -3
  35. data/po/it/gettext.edit.po +33 -25
  36. data/po/it/gettext.po +9 -3
  37. data/po/ja/gettext.edit.po +33 -25
  38. data/po/ja/gettext.po +9 -3
  39. data/po/ko/gettext.edit.po +33 -25
  40. data/po/ko/gettext.po +9 -3
  41. data/po/lv/gettext.edit.po +33 -25
  42. data/po/lv/gettext.po +9 -3
  43. data/po/nb/gettext.edit.po +33 -25
  44. data/po/nb/gettext.po +9 -3
  45. data/po/nl/gettext.edit.po +33 -25
  46. data/po/nl/gettext.po +9 -3
  47. data/po/pt_BR/gettext.edit.po +33 -25
  48. data/po/pt_BR/gettext.po +9 -3
  49. data/po/ru/gettext.edit.po +33 -25
  50. data/po/ru/gettext.po +9 -3
  51. data/po/sr/gettext.edit.po +33 -25
  52. data/po/sr/gettext.po +9 -3
  53. data/po/sv/gettext.edit.po +33 -25
  54. data/po/sv/gettext.po +9 -3
  55. data/po/uk/gettext.edit.po +33 -25
  56. data/po/uk/gettext.po +9 -3
  57. data/po/vi/gettext.edit.po +33 -25
  58. data/po/vi/gettext.po +9 -3
  59. data/po/zh/gettext.edit.po +33 -25
  60. data/po/zh/gettext.po +9 -3
  61. data/po/zh_TW/gettext.edit.po +33 -25
  62. data/po/zh_TW/gettext.po +9 -3
  63. data/test/fixtures/_/percent_strings.rb +9 -0
  64. data/test/fixtures/_/pipe.rb +32 -0
  65. data/test/fixtures/erb/minus.rhtml +12 -0
  66. data/test/fixtures/gtk_builder_ui_definitions.ui~ +68 -0
  67. data/test/fixtures/ruby/percent_I.rb +1 -0
  68. data/test/fixtures/ruby/percent_W.rb +1 -0
  69. data/test/fixtures/ruby/percent_i.rb +1 -0
  70. data/test/fixtures/ruby/percent_w.rb +1 -0
  71. data/test/run-test.rb +0 -1
  72. data/test/test_parser.rb +7 -0
  73. data/test/tools/parser/test_ruby.rb +52 -2
  74. data/test/tools/test_msgmerge.rb +34 -0
  75. metadata +21 -29
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f6b8ac74bbe41d5b0a942c489cdc9d4c99ccde14e4e8fd7332168e85c0711c9
4
- data.tar.gz: 6644e0c768ad64cc2e6339809953bbcab6198b5fed86d7fb84d76d97b74f3850
3
+ metadata.gz: '062339537f378d590d0257675937b866739f3fabefab874a71e22c4962081dd0'
4
+ data.tar.gz: 45b32dc00ca6d62925de104a25814309f6ec3c3db9407feb6530808f4c273fd7
5
5
  SHA512:
6
- metadata.gz: b3cc2e18fcb5e68a66678d359a325b3af5c4b74a9cea7a595066022984c172cefacafd9272cb688167b4eab09bc21f9acede3f6ee567feb1ce6344dc0448ce98
7
- data.tar.gz: 71995c31d3eba398f1680295fa59c4c00454306460522a962ebd2107c36c80320395ee63d1883dc331ca4c8455b8147d65efc451f81f16a20844a1934718c351
6
+ metadata.gz: c9d94745d0acd678adcc0b9e26eb5e862e4b02dbe12ad8b51f77860860eb941bea5b29f6178db92df02ed2ee496a0aa0153ac3e72655d16f398be98ff6f7e470
7
+ data.tar.gz: e23e77aba1d2cf1a3b2d1bd3b682b2639837d8539df973cc9d56a1361f26b6f6200d6305516bda527d02670fe67e09d630f733a755e2462d319b7b06c3e22547
@@ -1,5 +1,68 @@
1
1
  # News
2
2
 
3
+ ## 3.3.7: 2021-01-18 {#version-3-3-7}
4
+
5
+ ### Improvements
6
+
7
+ * msgmerge: Added `--no-report-warning` option.
8
+ [GitHub#81][Reported by Akim Demaille]
9
+
10
+ ### Thanks
11
+
12
+ * Akim Demaille
13
+
14
+ ## 3.3.6: 2020-08-04 {#version-3-3-6}
15
+
16
+ ### Improvements
17
+
18
+ * erb: Added support for `-%>`.
19
+ [GitHub#77][Reported by lremes]
20
+
21
+ * Removed ChangeLog.
22
+ [GitHub#76][Reported by Will Stephenson]
23
+
24
+ * Don't assume `RbConfig::CONFIG["datadir"]` is available. For
25
+ example, TruffleRuby doesn't provide it.
26
+
27
+ ### Thanks
28
+
29
+ * lremes
30
+
31
+ * Will Stephenson
32
+
33
+ ## 3.3.5: 2020-02-15 {#version-3-3-5}
34
+
35
+ ### Improvements
36
+
37
+ * Added support for `|` method.
38
+ [GitHub#73][Reported by dorle-o]
39
+
40
+ ### Thanks
41
+
42
+ * dorle-o
43
+
44
+ ## 3.3.4: 2020-02-12 {#version-3-3-4}
45
+
46
+ ### Improvements
47
+
48
+ * Added support for `%W`.
49
+ [GitHub#72][Reported by Michaël Hoste]
50
+
51
+ ### Thanks
52
+
53
+ * Michaël Hoste
54
+
55
+ ## 3.3.3: 2020-02-05 {#version-3-3-3}
56
+
57
+ ### Improvements
58
+
59
+ * Added support for `%I`.
60
+ [GitHub#71][Reported by Kai Ramuenke]
61
+
62
+ ### Thanks
63
+
64
+ * Kai Ramuenke
65
+
3
66
  ## 3.3.2: 2020-01-13 {#version-3-3-2}
4
67
 
5
68
  ### Fixes
@@ -817,3 +880,157 @@ Ruby 1.9 support release.
817
880
  * Gunnar Wolf
818
881
  * Ivan Pirlik
819
882
  * Tatsuki Sugiura
883
+
884
+ ## 2.2.1: 2012-05-20
885
+
886
+ ### Changes
887
+
888
+ * Supported non ASCII string in msgid. [GitHub#1]
889
+ [Patch by Urban Hafner]
890
+ * Stopped overriding String#% on Ruby 1.9.
891
+ * Fixed a bug that "\" is too escaped.
892
+ * Removed GetText.bindtext dependency from GetText::PoParser.
893
+ * Ranamed GetText::MOFile to GetText::MoFile but GetText::MOFile
894
+ is still available.
895
+
896
+ ### Thanks
897
+
898
+ * Urban Hafner
899
+
900
+ ## 2.2.0: 2012-03-11
901
+
902
+ ### Changes
903
+
904
+ * Supported ruby-1.9. [Patch by hallelujah]
905
+ * Supported $SAFE=1. [Patch by bon]
906
+ * Improved argument check. [Suggested by Morus Walter]
907
+ * Supported ruby-1.8.6 again. [Bug#27447] [Reported by Mamoru Tasaka]
908
+ * Fixed Ukrainan translation path. [Bug#28277] [Reported by Gunnar Wolf]
909
+ * Fixed a bug that only the last path in GETTEXT_PATH environment
910
+ variable is used. [Bug#28345] [Reported by Ivan Pirlik]
911
+ * Fixed a bug that Ruby-GetText-Package modifies $LOAD_PATH. [Bug#28094]
912
+ [Reported by Tatsuki Sugiura]
913
+
914
+ ### Thanks
915
+
916
+ * hallelujah
917
+ * bon
918
+ * Morus Walter
919
+ * Mamoru Tasaka
920
+ * Gunnar Wolf
921
+ * Ivan Pirlik
922
+ * Tatsuki Sugiura
923
+
924
+
925
+ ## 2.1.0: 2009-11-14
926
+
927
+ ### Changes
928
+
929
+ * Implemented parsing of translator comments (GNU gettext feature)
930
+ [by Vladimir Dobriakov]
931
+ * Refactor the directory structure.
932
+ * Move files for runtime to lib/gettext/runtime/*.
933
+ * Move files for development(rgettext/rmsgfmt) to
934
+ lib/gettext/tools/*.
935
+ * Refactor parsers for po. po-message object is defined as GetText::PoMessage
936
+ class. [by Vladimir Dobriakov, Masao Mutoh]
937
+ * Speed up when lots of objects are created to share the textdomain in each
938
+ objects. [Reported by Gaël Séchaud.]
939
+ * Fix "%{foo.bar}" %{"foo.bar".to_sym => "a"} doesn't work.
940
+ [Bug#26663, Reported by Danilo Castilho]
941
+ * lib/gettext.rb: Fixed to work unless gem. [Reported by Vladimir Dobriakov]
942
+ * Fixed a wrong String literal in a CGI sample.
943
+ [Bug #26531, by Eugene Mikhailov]
944
+ * Update license information(explicit to use ruby's or LGPL).
945
+ [Pointed out by Masateru Yoshikawa]
946
+ * Code cleanup.
947
+ * Update minor version.
948
+
949
+ ## 2.0.4: 2009-05-23
950
+
951
+ ### Changes
952
+
953
+ * Fix String#% return nil when the string have no place holders. [by okkez]
954
+ * Update pofiles and remove old messages.
955
+ * suppress some warnings on Ruby 1.9.x. [by Nobuhiro IMAI]
956
+ * Fix not to run tests on Win32.
957
+
958
+ ## 2.0.3: 2009-05-09
959
+
960
+ ### Changes
961
+
962
+ * Fixed the dependencies. [Reported by Hans de Graaff]
963
+
964
+ ## 2.0.2: 2009-05-04
965
+
966
+ ### Changes
967
+
968
+ * Support ruby-1.9.1 style format string such as `%<foo>d`.
969
+ * Apply new `Locale.set_app_language_tags` and Locale.candidates.
970
+ [Suggested by Vladimir Dobriakov]
971
+ * Enhance to support ruby-1.9.x [by OZAWA Sakuro]
972
+ * poparser work with proper encoding.
973
+ * string.rb: #bytesize alias to #size in older ruby version such as 1.8.5.
974
+ * Fixed bugs
975
+ * `n_()` to work when Plural-Forms line in po-file is not correct.
976
+ [Reported by Sava Chankov (Bug#25570)]
977
+ * GetText::Locale.default_rules_path : $LOAD_PATH is not well parsed.
978
+ [by hallelujah]
979
+ * locale_path.rb: Fixed warning message.
980
+
981
+ ### Thanks
982
+
983
+ * hallelujah
984
+ * Sava Chankov
985
+ * OZAWA Sakuro
986
+ * Vladimir Dobriakov
987
+
988
+ ## 2.0.1: 2009-04-17
989
+
990
+ ### Changes
991
+
992
+ * Fixed bugs
993
+ * doesn't work with ruby-1.8.5. [Reported by Dan Coutu]
994
+ * GetText.locale= can't keep the locale. [Reported by Adam Ilan]
995
+ * Break backward compatibility of bindtextdomain
996
+ [Reported by Mamoru Tasaka(#24947), Mathieu Blondel]
997
+ * Other trivial fixes/improvement.
998
+ * 1.8 times faster than 2.0.0.
999
+ * GetText::LocalePath is separated from GetText::TextDomainManager.
1000
+ Improve to find the locale path.
1001
+ * Enhance to support ruby-1.9.x [by OZAWA Sakuro]
1002
+
1003
+ ### Thanks
1004
+
1005
+ * OZAWA Sakuro
1006
+ * Tietew
1007
+ * Adam Ilan
1008
+ * Mamoru Tasaka
1009
+ * Mathieu Blondel
1010
+
1011
+ ## 2.0.0: 2009-03-21
1012
+
1013
+ ### Changes
1014
+
1015
+ * Separate this library to locale and rails-support to locale,
1016
+ locale\_rails, gettext\_activerecord, gettext\_rails.
1017
+ * Depends on locale(ruby-locale).
1018
+ * Removes to support rails.
1019
+ * A lot of referctoring, improvements.
1020
+ * Thread safe.
1021
+ * New APIs for gettext/tools instead of gettext/utils.
1022
+ * Move to github.com.
1023
+
1024
+ ### Special thanks
1025
+
1026
+ * Michael Grosser: A lot of improvement.
1027
+
1028
+ ### Thanks
1029
+
1030
+ * Tietew
1031
+ * Kazuhiro NISHIYAMA
1032
+ * Fabio M.A.
1033
+ * Tuptus
1034
+ * Morus Walter
1035
+ * Vladimir Dobriakov
1036
+ * Ramsey
@@ -36,7 +36,6 @@ So you can use GNU gettext tools for maintaining.
36
36
  s.add_development_dependency("yard")
37
37
  s.add_development_dependency("kramdown")
38
38
  s.add_development_dependency("test-unit")
39
- s.add_development_dependency("test-unit-notify")
40
39
  s.add_development_dependency("test-unit-rr")
41
40
  s.license = "Ruby or LGPLv3+"
42
41
  end
@@ -17,14 +17,18 @@ module GetText
17
17
  class LocalePath
18
18
  # The default locale paths.
19
19
  CONFIG_PREFIX = RbConfig::CONFIG['prefix'].gsub(/\/local/, "")
20
- DEFAULT_RULES = [
21
- "./locale/%{lang}/LC_MESSAGES/%{name}.mo",
22
- "./locale/%{lang}/%{name}.mo",
23
- "#{RbConfig::CONFIG['datadir']}/locale/%{lang}/LC_MESSAGES/%{name}.mo",
24
- "#{RbConfig::CONFIG['datadir'].gsub(/\/local/, "")}/locale/%{lang}/LC_MESSAGES/%{name}.mo",
25
- "#{CONFIG_PREFIX}/share/locale/%{lang}/LC_MESSAGES/%{name}.mo",
26
- "#{CONFIG_PREFIX}/local/share/locale/%{lang}/LC_MESSAGES/%{name}.mo"
27
- ].uniq
20
+ default_rules_candidates = [
21
+ "./locale/%{lang}/LC_MESSAGES/%{name}.mo",
22
+ "./locale/%{lang}/%{name}.mo",
23
+ ]
24
+ data_dir = RbConfig::CONFIG["datadir"]
25
+ if data_dir
26
+ default_rules_candidates << "#{data_dir}/locale/%{lang}/LC_MESSAGES/%{name}.mo"
27
+ default_rules_candidates << "#{data_dir.gsub(/\/local/, "")}/locale/%{lang}/LC_MESSAGES/%{name}.mo"
28
+ end
29
+ default_rules_candidates << "#{CONFIG_PREFIX}/share/locale/%{lang}/LC_MESSAGES/%{name}.mo"
30
+ default_rules_candidates << "#{CONFIG_PREFIX}/local/share/locale/%{lang}/LC_MESSAGES/%{name}.mo"
31
+ DEFAULT_RULES = default_rules_candidates.uniq
28
32
 
29
33
  class << self
30
34
  # Add default locale path. Usually you should use GetText.add_default_locale_path instead.
@@ -49,6 +49,7 @@ module GetText
49
49
  config.parse(command_line)
50
50
 
51
51
  parser = POParser.new
52
+ parser.report_warning = config.report_warning?
52
53
  parser.ignore_fuzzy = false
53
54
  definition_po = PO.new
54
55
  reference_pot = PO.new
@@ -313,6 +314,7 @@ module GetText
313
314
  }
314
315
  @enable_fuzzy_matching = true
315
316
  @update = nil
317
+ @report_warning = true
316
318
  @output_obsolete_entries = true
317
319
  @backup = ENV["VERSION_CONTROL"]
318
320
  @suffix = ENV["SIMPLE_BACKUP_SUFFIX"] || "~"
@@ -337,6 +339,12 @@ module GetText
337
339
  @enable_fuzzy_matching
338
340
  end
339
341
 
342
+ # @return [Bool] true if reporting warning is enabled,
343
+ # false otherwise.
344
+ def report_warning?
345
+ @report_warning
346
+ end
347
+
340
348
  # @return [Bool] true if outputting obsolete entries is
341
349
  # enabled, false otherwise.
342
350
  def output_obsolete_entries?
@@ -422,6 +430,11 @@ module GetText
422
430
  @enable_fuzzy_matching = boolean
423
431
  end
424
432
 
433
+ parser.on("--no-report-warning",
434
+ _("Don't report warning messages")) do |report_warning|
435
+ @report_warning = report_warning
436
+ end
437
+
425
438
  parser.on("--no-obsolete-entries",
426
439
  _("Don't output obsolete entries")) do |boolean|
427
440
  @output_obsolete_entries = boolean
@@ -57,12 +57,20 @@ module GetText
57
57
  @options = options
58
58
  end
59
59
 
60
+ @@erb_accept_keyword_arguments =
61
+ ERB.instance_method(:initialize).parameters.any? {|type, _| type == :key}
62
+
60
63
  # Extracts messages from @path.
61
64
  #
62
65
  # @return [Array<POEntry>] Extracted messages
63
66
  def parse
64
67
  content = IO.read(@path)
65
- src = ERB.new(content).src
68
+ if @@erb_accept_keyword_arguments
69
+ erb = ERB.new(content, trim_mode: "-")
70
+ else
71
+ erb = ERB.new(content, nil, "-")
72
+ end
73
+ src = erb.src
66
74
 
67
75
  # Force the src encoding back to the encoding in magic comment
68
76
  # or original content.
@@ -50,9 +50,6 @@ module GetText
50
50
  end
51
51
  end
52
52
 
53
- TARGET1 = /<property.*translatable="yes">(.*)/
54
- TARGET2 = /(.*)<\/property>/
55
-
56
53
  def initialize(path, options={})
57
54
  @path = path
58
55
  @options = options
@@ -28,9 +28,9 @@ module GetText
28
28
  attr_accessor :comment_tag
29
29
  def initialize(*args)
30
30
  super(*args)
31
+ @start_block = false
31
32
  @in_block_arguments = false
32
33
  @ignore_next_comma = false
33
- @context_stack = []
34
34
  @need_definition_name = false
35
35
  @current_po_entry = nil
36
36
  @current_po_entry_nth_attribute = 0
@@ -43,28 +43,31 @@ module GetText
43
43
  end
44
44
 
45
45
  def process_on_op(token, po)
46
- @in_block_arguments = !@in_block_arguments if token == "|"
46
+ if @start_block
47
+ @in_block_arguments = (token == "|")
48
+ else
49
+ if @in_block_arguments and token == "|"
50
+ @in_block_arguments = false
51
+ end
52
+ end
47
53
  po
48
54
  end
49
55
 
50
56
  def process_on_kw(token, po)
51
57
  store_po_entry(po)
52
58
  case token
53
- when "begin", "case", "do", "for"
54
- @context_stack.push(token)
55
- when "class", "def", "module"
56
- @context_stack.push(token)
57
- when "if", "unless", "until", "while"
58
- # postfix case
59
- unless state.allbits?(Ripper::EXPR_LABEL)
60
- @context_stack.push(token)
61
- end
62
- when "end"
63
- @context_stack.pop
59
+ when "do"
60
+ @start_block = true
64
61
  end
65
62
  po
66
63
  end
67
64
 
65
+ def process_on_lbrace(token, po)
66
+ store_po_entry(po)
67
+ @start_block = (state == Ripper::EXPR_BEG)
68
+ po
69
+ end
70
+
68
71
  def process_on_ident(token, po)
69
72
  store_po_entry(po)
70
73
 
@@ -203,18 +206,18 @@ module GetText
203
206
  po
204
207
  end
205
208
 
206
- def process_on_embexpr_beg(token, po)
207
- @current_po_entry = nil
208
- @current_po_entry_nth_attribute = 0
209
- po
210
- end
211
-
212
209
  def process_on_regexp_end(token, po)
213
210
  @string_mark_stack.pop
214
211
  @string_stack.pop
215
212
  po
216
213
  end
217
214
 
215
+ def process_on_embexpr_beg(token, po)
216
+ @current_po_entry = nil
217
+ @current_po_entry_nth_attribute = 0
218
+ po
219
+ end
220
+
218
221
  def process_on_int(token, po)
219
222
  @ignore_next_comma = true
220
223
  po
@@ -253,12 +256,24 @@ module GetText
253
256
  po
254
257
  end
255
258
 
259
+ def process_on_symbols_beg(token, po)
260
+ @string_mark_stack << "\""
261
+ @string_stack << ""
262
+ po
263
+ end
264
+
256
265
  def process_on_qsymbols_beg(token, po)
257
266
  @string_mark_stack << token
258
267
  @string_stack << ""
259
268
  po
260
269
  end
261
270
 
271
+ def process_on_words_beg(token, po)
272
+ @string_mark_stack << "\""
273
+ @string_stack << ""
274
+ po
275
+ end
276
+
262
277
  def process_on_qwords_beg(token, po)
263
278
  @string_mark_stack << token
264
279
  @string_stack << ""
@@ -268,11 +283,14 @@ module GetText
268
283
  def on_default(event, token, po)
269
284
  trace(event, token) do
270
285
  process_method = "process_#{event}"
286
+ start_block = @start_block
271
287
  if respond_to?(process_method)
272
- __send__(process_method, token, po)
273
- else
274
- po
288
+ po = __send__(process_method, token, po)
289
+ end
290
+ if start_block and event != :on_sp
291
+ @start_block = false
275
292
  end
293
+ po
276
294
  end
277
295
  end
278
296
 
@@ -283,7 +301,16 @@ module GetText
283
301
  end
284
302
 
285
303
  def trace(event_name, token)
286
- pp [event_name, token, state, @context_stack.last] if debug?
304
+ if debug?
305
+ status = [
306
+ event_name,
307
+ token,
308
+ state,
309
+ ]
310
+ status << :start_block if @start_block
311
+ status << :in_block_arguments if @in_block_arguments
312
+ pp status
313
+ end
287
314
  yield
288
315
  end
289
316