gettext 3.3.3 → 3.3.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +4 -0
- data/doc/text/news.md +231 -0
- data/gettext.gemspec +1 -1
- data/lib/gettext/locale_path.rb +12 -8
- data/lib/gettext/mo.rb +7 -5
- data/lib/gettext/tools/msginit.rb +216 -50
- data/lib/gettext/tools/msgmerge.rb +13 -0
- data/lib/gettext/tools/parser/erb.rb +9 -1
- data/lib/gettext/tools/parser/glade.rb +38 -40
- data/lib/gettext/tools/parser/gtk_builder_ui_definitions.rb +6 -6
- data/lib/gettext/tools/parser/ruby.rb +50 -29
- data/lib/gettext/version.rb +2 -2
- data/locale/bg/LC_MESSAGES/gettext.mo +0 -0
- data/locale/bs/LC_MESSAGES/gettext.mo +0 -0
- data/locale/ca/LC_MESSAGES/gettext.mo +0 -0
- data/locale/cs/LC_MESSAGES/gettext.mo +0 -0
- data/locale/de/LC_MESSAGES/gettext.mo +0 -0
- data/locale/el/LC_MESSAGES/gettext.mo +0 -0
- data/locale/eo/LC_MESSAGES/gettext.mo +0 -0
- data/locale/es/LC_MESSAGES/gettext.mo +0 -0
- data/locale/et/LC_MESSAGES/gettext.mo +0 -0
- data/locale/fr/LC_MESSAGES/gettext.mo +0 -0
- data/locale/hr/LC_MESSAGES/gettext.mo +0 -0
- data/locale/hu/LC_MESSAGES/gettext.mo +0 -0
- data/locale/it/LC_MESSAGES/gettext.mo +0 -0
- data/locale/ja/LC_MESSAGES/gettext.mo +0 -0
- data/locale/ko/LC_MESSAGES/gettext.mo +0 -0
- data/locale/lv/LC_MESSAGES/gettext.mo +0 -0
- data/locale/nb/LC_MESSAGES/gettext.mo +0 -0
- data/locale/nl/LC_MESSAGES/gettext.mo +0 -0
- data/locale/pt_BR/LC_MESSAGES/gettext.mo +0 -0
- data/locale/ru/LC_MESSAGES/gettext.mo +0 -0
- data/locale/sr/LC_MESSAGES/gettext.mo +0 -0
- data/locale/uk/LC_MESSAGES/gettext.mo +0 -0
- data/locale/vi/LC_MESSAGES/gettext.mo +0 -0
- data/locale/zh/LC_MESSAGES/gettext.mo +0 -0
- data/locale/zh_TW/LC_MESSAGES/gettext.mo +0 -0
- data/po/bg/gettext.edit.po +36 -554
- data/po/bg/gettext.po +0 -423
- data/po/bs/gettext.edit.po +36 -554
- data/po/bs/gettext.po +0 -423
- data/po/ca/gettext.edit.po +36 -554
- data/po/ca/gettext.po +0 -423
- data/po/cs/gettext.edit.po +36 -554
- data/po/cs/gettext.po +0 -423
- data/po/de/gettext.edit.po +36 -554
- data/po/de/gettext.po +0 -423
- data/po/el/gettext.edit.po +36 -554
- data/po/el/gettext.po +0 -423
- data/po/eo/gettext.edit.po +36 -554
- data/po/eo/gettext.po +0 -423
- data/po/es/gettext.edit.po +36 -554
- data/po/es/gettext.po +0 -423
- data/po/et/gettext.edit.po +36 -554
- data/po/et/gettext.po +0 -423
- data/po/fr/gettext.edit.po +36 -554
- data/po/fr/gettext.po +0 -423
- data/po/gettext.pot +37 -619
- data/po/hr/gettext.edit.po +36 -554
- data/po/hr/gettext.po +0 -423
- data/po/hu/gettext.edit.po +36 -554
- data/po/hu/gettext.po +0 -423
- data/po/it/gettext.edit.po +36 -554
- data/po/it/gettext.po +0 -423
- data/po/ja/gettext.edit.po +36 -554
- data/po/ja/gettext.po +0 -423
- data/po/ko/gettext.edit.po +36 -554
- data/po/ko/gettext.po +0 -423
- data/po/lv/gettext.edit.po +36 -554
- data/po/lv/gettext.po +0 -423
- data/po/nb/gettext.edit.po +36 -554
- data/po/nb/gettext.po +0 -423
- data/po/nl/gettext.edit.po +36 -554
- data/po/nl/gettext.po +0 -423
- data/po/pt_BR/gettext.edit.po +36 -554
- data/po/pt_BR/gettext.po +0 -423
- data/po/ru/gettext.edit.po +36 -554
- data/po/ru/gettext.po +0 -423
- data/po/sr/gettext.edit.po +36 -554
- data/po/sr/gettext.po +0 -423
- data/po/sv/gettext.edit.po +34 -555
- data/po/sv/gettext.po +0 -423
- data/po/uk/gettext.edit.po +36 -554
- data/po/uk/gettext.po +0 -423
- data/po/vi/gettext.edit.po +36 -554
- data/po/vi/gettext.po +0 -423
- data/po/zh/gettext.edit.po +36 -554
- data/po/zh/gettext.po +0 -423
- data/po/zh_TW/gettext.edit.po +36 -554
- data/po/zh_TW/gettext.po +0 -423
- data/test/fixtures/_.rb +1 -1
- data/test/fixtures/_/pipe.rb +32 -0
- data/test/fixtures/erb/minus.rhtml +12 -0
- data/test/fixtures/{gladeparser.glade → glade/2.glade} +0 -0
- data/test/fixtures/glade/3.glade +63 -0
- data/test/fixtures/gtk_builder_ui_definitions.ui~ +68 -0
- data/test/fixtures/multi_text_domain.rb +12 -12
- data/test/fixtures/np_.rb +1 -1
- data/test/fixtures/ns_.rb +1 -1
- data/test/fixtures/p_.rb +1 -1
- data/test/fixtures/ruby/percent_lower_i.rb +1 -0
- data/test/fixtures/ruby/percent_lower_w.rb +1 -0
- data/test/fixtures/ruby/percent_upper_i.rb +1 -0
- data/test/fixtures/ruby/percent_upper_w.rb +1 -0
- data/test/fixtures/s_.rb +1 -1
- data/test/fixtures/simple.rb +1 -1
- data/test/fixtures/upper_nn_.rb +77 -0
- data/test/po/_.pot +20 -4
- data/test/po/ja/_.edit.po +24 -0
- data/test/po/np_.pot +8 -5
- data/test/po/ns_.pot +6 -4
- data/test/po/p_.pot +3 -3
- data/test/po/s_.pot +6 -4
- data/test/run-test.rb +0 -1
- data/test/test_parser.rb +42 -17
- data/test/tools/parser/test_glade.rb +91 -0
- data/test/tools/parser/test_gtk_builder_ui_definitions.rb +19 -1
- data/test/tools/parser/test_ruby.rb +42 -0
- data/test/tools/test_msginit.rb +77 -3
- data/test/tools/test_msgmerge.rb +34 -0
- metadata +37 -28
@@ -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
|
-
|
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.
|
@@ -1,14 +1,20 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
1
|
+
# Copyright (C) 2004,2005 Masao Mutoh
|
2
|
+
# Copyright (C) 2013 Kouhei Sutou <kou@clear-code.com>
|
3
|
+
#
|
4
|
+
# License: Ruby's or LGPL
|
5
|
+
#
|
6
|
+
# This library is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# This library is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU Lesser General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU Lesser General Public License
|
17
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
12
18
|
|
13
19
|
require 'cgi'
|
14
20
|
require 'gettext'
|
@@ -24,15 +30,11 @@ module GetText
|
|
24
30
|
GLADE_RE = /glade-2.0.dtd/
|
25
31
|
|
26
32
|
def target?(file) # :nodoc:
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
raise _("`%{file}' is not glade-2.0 format.") % {:file => file}
|
33
|
-
end
|
34
|
-
false
|
35
|
-
end
|
33
|
+
return false unless File.extname(file) == ".glade"
|
34
|
+
data = File.read(file)
|
35
|
+
return false unless data.include?("<?xml")
|
36
|
+
return false unless data.include?("glade-2.0.dtd")
|
37
|
+
true
|
36
38
|
end
|
37
39
|
|
38
40
|
def parse(path, options={})
|
@@ -57,7 +59,7 @@ module GetText
|
|
57
59
|
|
58
60
|
private
|
59
61
|
def parse_source(input) # :nodoc:
|
60
|
-
|
62
|
+
po = []
|
61
63
|
target = false
|
62
64
|
start_line_no = nil
|
63
65
|
val = nil
|
@@ -69,14 +71,14 @@ module GetText
|
|
69
71
|
target = true
|
70
72
|
if TARGET2 =~ $1
|
71
73
|
val = $1
|
72
|
-
|
74
|
+
add_po_entry(po, val, start_line_no)
|
73
75
|
val = nil
|
74
76
|
target = false
|
75
77
|
end
|
76
78
|
elsif target
|
77
79
|
if TARGET2 =~ line
|
78
80
|
val << $1
|
79
|
-
|
81
|
+
add_po_entry(po, val, start_line_no)
|
80
82
|
val = nil
|
81
83
|
target = false
|
82
84
|
else
|
@@ -84,26 +86,22 @@ module GetText
|
|
84
86
|
end
|
85
87
|
end
|
86
88
|
end
|
87
|
-
|
89
|
+
po
|
88
90
|
end
|
89
91
|
|
90
|
-
def
|
91
|
-
return
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
else
|
97
|
-
targets << [val.gsub(/\n/, '\n'), "#{@path}:#{line_no}"]
|
92
|
+
def add_po_entry(po, value, line_no) # :nodoc:
|
93
|
+
return if value.empty?
|
94
|
+
value = CGI.unescapeHTML(value)
|
95
|
+
value = value.gsub(/\n/, "\n")
|
96
|
+
po_entry = po.find do |entry|
|
97
|
+
entry.msgid == value
|
98
98
|
end
|
99
|
-
|
99
|
+
if po_entry.nil?
|
100
|
+
po_entry = POEntry.new(:normal)
|
101
|
+
po_entry.msgid = value
|
102
|
+
po << po_entry
|
103
|
+
end
|
104
|
+
po_entry.references << "#{@path}:#{line_no}"
|
100
105
|
end
|
101
106
|
end
|
102
107
|
end
|
103
|
-
|
104
|
-
if __FILE__ == $0
|
105
|
-
# ex) ruby glade.rb foo.glade bar.glade
|
106
|
-
ARGV.each do |file|
|
107
|
-
p GetText::GladeParser.parse(file)
|
108
|
-
end
|
109
|
-
end
|
@@ -24,13 +24,14 @@ require "gettext/po_entry"
|
|
24
24
|
module GetText
|
25
25
|
class GtkBuilderUIDefinitionsParser
|
26
26
|
@config = {
|
27
|
-
:extnames => [".ui"]
|
27
|
+
:extnames => [".ui", ".glade"]
|
28
28
|
}
|
29
29
|
|
30
30
|
class << self
|
31
31
|
# Sets some preferences to parse GtkBuilder UI definitions files.
|
32
32
|
# * config: a Hash of the config. It can takes some values below:
|
33
|
-
# * :extnames: An Array of target files extension.
|
33
|
+
# * :extnames: An Array of target files extension.
|
34
|
+
# Default is [".ui", ".glade"].
|
34
35
|
def init(config)
|
35
36
|
config.each do |k, v|
|
36
37
|
@config[k] = v
|
@@ -39,7 +40,9 @@ module GetText
|
|
39
40
|
|
40
41
|
def target?(file) # :nodoc:
|
41
42
|
@config[:extnames].each do |extname|
|
42
|
-
|
43
|
+
next unless File.extname(file) == extname
|
44
|
+
next unless File.read(file).include?("<interface>")
|
45
|
+
return true
|
43
46
|
end
|
44
47
|
false
|
45
48
|
end
|
@@ -50,9 +53,6 @@ module GetText
|
|
50
53
|
end
|
51
54
|
end
|
52
55
|
|
53
|
-
TARGET1 = /<property.*translatable="yes">(.*)/
|
54
|
-
TARGET2 = /(.*)<\/property>/
|
55
|
-
|
56
56
|
def initialize(path, options={})
|
57
57
|
@path = path
|
58
58
|
@options = options
|
@@ -1,7 +1,7 @@
|
|
1
1
|
=begin
|
2
2
|
parser/ruby.rb - parser for ruby script
|
3
3
|
|
4
|
-
Copyright (C) 2013-
|
4
|
+
Copyright (C) 2013-2021 Sutou Kouhei <kou@clear-code.com>
|
5
5
|
Copyright (C) 2003-2009 Masao Mutoh
|
6
6
|
Copyright (C) 2005 speakillof
|
7
7
|
Copyright (C) 2001,2002 Yasushi Shoji, Masao Mutoh
|
@@ -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
|
-
|
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 "
|
54
|
-
@
|
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
|
|
@@ -92,7 +95,7 @@ module GetText
|
|
92
95
|
|
93
96
|
def process_on_const(token, po)
|
94
97
|
case token
|
95
|
-
when "N_","
|
98
|
+
when "N_", "Nn_"
|
96
99
|
# TODO: Check the next token is :on_lparen
|
97
100
|
process_on_ident(token, po)
|
98
101
|
else
|
@@ -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
|
@@ -247,14 +250,14 @@ module GetText
|
|
247
250
|
po
|
248
251
|
end
|
249
252
|
|
250
|
-
def
|
251
|
-
@string_mark_stack << "
|
253
|
+
def process_on_backtick(token, po)
|
254
|
+
@string_mark_stack << "`"
|
252
255
|
@string_stack << ""
|
253
256
|
po
|
254
257
|
end
|
255
258
|
|
256
|
-
def
|
257
|
-
@string_mark_stack << "
|
259
|
+
def process_on_symbols_beg(token, po)
|
260
|
+
@string_mark_stack << "\""
|
258
261
|
@string_stack << ""
|
259
262
|
po
|
260
263
|
end
|
@@ -265,6 +268,12 @@ module GetText
|
|
265
268
|
po
|
266
269
|
end
|
267
270
|
|
271
|
+
def process_on_words_beg(token, po)
|
272
|
+
@string_mark_stack << "\""
|
273
|
+
@string_stack << ""
|
274
|
+
po
|
275
|
+
end
|
276
|
+
|
268
277
|
def process_on_qwords_beg(token, po)
|
269
278
|
@string_mark_stack << token
|
270
279
|
@string_stack << ""
|
@@ -274,11 +283,14 @@ module GetText
|
|
274
283
|
def on_default(event, token, po)
|
275
284
|
trace(event, token) do
|
276
285
|
process_method = "process_#{event}"
|
286
|
+
start_block = @start_block
|
277
287
|
if respond_to?(process_method)
|
278
|
-
__send__(process_method, token, po)
|
279
|
-
|
280
|
-
|
288
|
+
po = __send__(process_method, token, po)
|
289
|
+
end
|
290
|
+
if start_block and event != :on_sp
|
291
|
+
@start_block = false
|
281
292
|
end
|
293
|
+
po
|
282
294
|
end
|
283
295
|
end
|
284
296
|
|
@@ -289,7 +301,16 @@ module GetText
|
|
289
301
|
end
|
290
302
|
|
291
303
|
def trace(event_name, token)
|
292
|
-
|
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
|
293
314
|
yield
|
294
315
|
end
|
295
316
|
|
data/lib/gettext/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
=begin
|
2
2
|
version - version information of gettext
|
3
3
|
|
4
|
-
Copyright (C) 2012-
|
4
|
+
Copyright (C) 2012-2021 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.3.
|
12
|
+
VERSION = "3.3.8"
|
13
13
|
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|