gettext 2.3.6 → 2.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/doc/text/news.md +15 -1
- data/lib/gettext/tools/msgmerge.rb +13 -8
- data/lib/gettext/tools/po.rb +1 -1
- data/lib/gettext/tools/po_entry.rb +15 -9
- data/lib/gettext/tools/poparser.rb +16 -12
- data/lib/gettext/version.rb +1 -1
- data/locale/ja/LC_MESSAGES/gettext.mo +0 -0
- data/po/ja/gettext.po +71 -31
- data/src/poparser.ry +16 -12
- data/test/tools/test_msgmerge.rb +91 -77
- metadata +4 -4
data/doc/text/news.md
CHANGED
@@ -1,4 +1,19 @@
|
|
1
1
|
# News
|
2
|
+
|
3
|
+
## <a id="2-3-7">2.3.7</a>: 2013-01-11
|
4
|
+
|
5
|
+
This is a msgmerge improved release.
|
6
|
+
|
7
|
+
### Improvements
|
8
|
+
|
9
|
+
* [msgmerge] Speeded up fuzzy matching.
|
10
|
+
|
11
|
+
### Fixes
|
12
|
+
|
13
|
+
* [msgmerge] Fix the bug that msgmerge adds needless fuzzy flag from
|
14
|
+
not fuzzy entries in merged PO.
|
15
|
+
* [POEntry] Pretty formated all messages except msgstr.
|
16
|
+
|
2
17
|
## <a id="2-3-6">2.3.6</a>: 2012-12-19
|
3
18
|
|
4
19
|
This is a bug fix release.
|
@@ -57,7 +72,6 @@ This is a many changes and new implements release.
|
|
57
72
|
* Raised no error when POEntry doesn't have references.
|
58
73
|
It is useful for no references in .PO file.
|
59
74
|
|
60
|
-
# News
|
61
75
|
## <a id="2-3-3">2.3.3</a>: 2012-10-18
|
62
76
|
|
63
77
|
It's a package fix and msginit improvement release.
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
|
+
# Copyright (C) 2012-2013 Haruka Yoshihara <yoshihara@clear-code.com>
|
3
4
|
# Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com>
|
4
5
|
# Copyright (C) 2005-2009 Masao Mutoh
|
5
6
|
# Copyright (C) 2005,2006 speakillof
|
@@ -229,15 +230,15 @@ module GetText
|
|
229
230
|
mark = $1
|
230
231
|
content = $2
|
231
232
|
case mark
|
232
|
-
when
|
233
|
+
when POEntry::TRANSLATOR_COMMENT_MARK
|
233
234
|
entry.translator_comment << "#{content}\n"
|
234
|
-
when
|
235
|
+
when POEntry::EXTRACTED_COMMENT_MARK
|
235
236
|
entry.extracted_comment << "#{content}\n"
|
236
|
-
when
|
237
|
+
when POEntry::REFERENCE_COMMENT_MARK
|
237
238
|
entry.references << content
|
238
|
-
when
|
239
|
+
when POEntry::FLAG_MARK
|
239
240
|
entry.flag << "#{content}\n"
|
240
|
-
when
|
241
|
+
when POEntry::PREVIOUS_COMMENT_MARK
|
241
242
|
entry.previous << "#{content}\n"
|
242
243
|
else
|
243
244
|
entry.comment << line
|
@@ -259,6 +260,10 @@ module GetText
|
|
259
260
|
def merge(definition, reference)
|
260
261
|
result = GetText::PO.new
|
261
262
|
|
263
|
+
translated_entries = definition.reject do |entry|
|
264
|
+
entry.msgstr.nil?
|
265
|
+
end
|
266
|
+
|
262
267
|
reference.each do |entry|
|
263
268
|
msgid = entry.msgid
|
264
269
|
msgctxt = entry.msgctxt
|
@@ -270,14 +275,14 @@ module GetText
|
|
270
275
|
end
|
271
276
|
|
272
277
|
if msgctxt.nil?
|
273
|
-
same_msgid_entry = find_by_msgid(
|
278
|
+
same_msgid_entry = find_by_msgid(translated_entries, msgid)
|
274
279
|
if not same_msgid_entry.nil? and not same_msgid_entry.msgctxt.nil?
|
275
280
|
result[nil, msgid] = merge_fuzzy_entry(same_msgid_entry, entry)
|
276
281
|
next
|
277
282
|
end
|
278
283
|
end
|
279
284
|
|
280
|
-
fuzzy_entry = find_fuzzy_entry(
|
285
|
+
fuzzy_entry = find_fuzzy_entry(translated_entries, msgid, msgctxt)
|
281
286
|
unless fuzzy_entry.nil?
|
282
287
|
result[*id] = merge_fuzzy_entry(fuzzy_entry, entry)
|
283
288
|
next
|
@@ -286,7 +291,7 @@ module GetText
|
|
286
291
|
result[*id] = entry
|
287
292
|
end
|
288
293
|
|
289
|
-
add_obsolete_entry(result,
|
294
|
+
add_obsolete_entry(result, translated_entries)
|
290
295
|
result
|
291
296
|
end
|
292
297
|
|
data/lib/gettext/tools/po.rb
CHANGED
@@ -55,8 +55,8 @@ module GetText
|
|
55
55
|
# @return [POEntry]
|
56
56
|
# @!macro po.[].argument
|
57
57
|
# @overload [](msgctxt, msgid)
|
58
|
+
# @param [String] msgctxt msgctxt contained returning {POEntry}.
|
58
59
|
# @!macro po.[].argument
|
59
|
-
# @param [String] msgid msgid contained returning {POEntry}.
|
60
60
|
def [](msgctxt, msgid=nil)
|
61
61
|
if msgid.nil?
|
62
62
|
msgid = msgctxt
|
@@ -45,6 +45,12 @@ module GetText
|
|
45
45
|
:msgctxt_plural => [:msgctxt, :msgid, :msgid_plural, :msgstr]
|
46
46
|
}
|
47
47
|
|
48
|
+
TRANSLATOR_COMMENT_MARK = "# "
|
49
|
+
EXTRACTED_COMMENT_MARK = "#."
|
50
|
+
FLAG_MARK = "#,"
|
51
|
+
PREVIOUS_COMMENT_MARK = "#|"
|
52
|
+
REFERENCE_COMMENT_MARK = "#:"
|
53
|
+
|
48
54
|
class << self
|
49
55
|
def escape(string)
|
50
56
|
string.gsub(/([\\"\n])/) do
|
@@ -193,10 +199,10 @@ module GetText
|
|
193
199
|
"msgid: #{msgid}"
|
194
200
|
raise(NoMsgctxtError, no_msgctxt_message)
|
195
201
|
end
|
196
|
-
str << "msgctxt
|
202
|
+
str << "msgctxt " << format_message(msgctxt)
|
197
203
|
end
|
198
204
|
|
199
|
-
str << "msgid
|
205
|
+
str << "msgid " << format_message(msgid)
|
200
206
|
if plural?
|
201
207
|
if @msgid_plural.nil?
|
202
208
|
no_plural_message = "This POEntry is a kind of plural " +
|
@@ -205,7 +211,7 @@ module GetText
|
|
205
211
|
raise(NoMsgidPluralError, no_plural_message)
|
206
212
|
end
|
207
213
|
|
208
|
-
str << "msgid_plural
|
214
|
+
str << "msgid_plural " << format_message(msgid_plural)
|
209
215
|
|
210
216
|
if msgstr.nil?
|
211
217
|
str << "msgstr[0] \"\"\n"
|
@@ -213,7 +219,7 @@ module GetText
|
|
213
219
|
else
|
214
220
|
msgstrs = msgstr.split("\000", -1)
|
215
221
|
msgstrs.each_with_index do |msgstr, index|
|
216
|
-
str << "msgstr[#{index}]
|
222
|
+
str << "msgstr[#{index}] " << format_message(msgstr)
|
217
223
|
end
|
218
224
|
end
|
219
225
|
else
|
@@ -228,19 +234,19 @@ module GetText
|
|
228
234
|
end
|
229
235
|
|
230
236
|
def format_extracted_comment
|
231
|
-
format_comment(
|
237
|
+
format_comment(EXTRACTED_COMMENT_MARK, extracted_comment)
|
232
238
|
end
|
233
239
|
|
234
240
|
def format_reference_comment
|
235
241
|
max_line_length = 70
|
236
242
|
formatted_reference = ""
|
237
243
|
if not references.nil? and not references.empty?
|
238
|
-
formatted_reference <<
|
244
|
+
formatted_reference << REFERENCE_COMMENT_MARK
|
239
245
|
line_size = 2
|
240
246
|
references.each do |reference|
|
241
247
|
if line_size + reference.size > max_line_length
|
242
248
|
formatted_reference << "\n"
|
243
|
-
formatted_reference << "
|
249
|
+
formatted_reference << "#{REFERENCE_COMMENT_MARK} #{reference}"
|
244
250
|
line_size = 3 + reference.size
|
245
251
|
else
|
246
252
|
formatted_reference << " #{reference}"
|
@@ -254,11 +260,11 @@ module GetText
|
|
254
260
|
end
|
255
261
|
|
256
262
|
def format_flag_comment
|
257
|
-
format_comment(
|
263
|
+
format_comment(FLAG_MARK, flag)
|
258
264
|
end
|
259
265
|
|
260
266
|
def format_previous_comment
|
261
|
-
format_comment(
|
267
|
+
format_comment(PREVIOUS_COMMENT_MARK, previous)
|
262
268
|
end
|
263
269
|
|
264
270
|
def format_comment(mark, comment)
|
@@ -17,11 +17,20 @@
|
|
17
17
|
require 'racc/parser.rb'
|
18
18
|
|
19
19
|
require "gettext/tools/po"
|
20
|
-
|
20
|
+
|
21
|
+
# For suppressing warning. PoData is deprecated and will be removed.
|
22
|
+
module GetText
|
23
|
+
module Tools
|
24
|
+
class MsgMerge
|
25
|
+
class PoData
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
21
30
|
module GetText
|
22
31
|
class POParser < Racc::Parser
|
23
32
|
|
24
|
-
module_eval(<<'...end poparser.ry/module_eval...', 'poparser.ry',
|
33
|
+
module_eval(<<'...end poparser.ry/module_eval...', 'poparser.ry', 132)
|
25
34
|
if GetText.respond_to?(:bindtextdomain)
|
26
35
|
include GetText
|
27
36
|
GetText.bindtextdomain("gettext")
|
@@ -184,11 +193,6 @@ module_eval(<<'...end poparser.ry/module_eval...', 'poparser.ry', 123)
|
|
184
193
|
comment
|
185
194
|
end
|
186
195
|
|
187
|
-
TRANSLATOR_COMMENT_MARK = "# "
|
188
|
-
EXTRACTED_COMMENT_MARK = "#."
|
189
|
-
FLAG_MARK = "#,"
|
190
|
-
PREVIOUS_MSGID_COMMENT_MARK = "#|"
|
191
|
-
REFERENCE_COMMENT_MARK = "#:"
|
192
196
|
def on_comment(comment)
|
193
197
|
@fuzzy = true if (/fuzzy/ =~ comment)
|
194
198
|
if @data.instance_of?(PO) or
|
@@ -199,15 +203,15 @@ module_eval(<<'...end poparser.ry/module_eval...', 'poparser.ry', 123)
|
|
199
203
|
mark = $1
|
200
204
|
content = $2
|
201
205
|
case mark
|
202
|
-
when TRANSLATOR_COMMENT_MARK
|
206
|
+
when POEntry::TRANSLATOR_COMMENT_MARK
|
203
207
|
@translator_comments << content
|
204
|
-
when EXTRACTED_COMMENT_MARK
|
208
|
+
when POEntry::EXTRACTED_COMMENT_MARK
|
205
209
|
@extracted_comments << content
|
206
|
-
when REFERENCE_COMMENT_MARK
|
210
|
+
when POEntry::REFERENCE_COMMENT_MARK
|
207
211
|
@references << content
|
208
|
-
when FLAG_MARK
|
212
|
+
when POEntry::FLAG_MARK
|
209
213
|
@flag << content
|
210
|
-
when
|
214
|
+
when POEntry::PREVIOUS_COMMENT_MARK
|
211
215
|
@previous << content
|
212
216
|
else
|
213
217
|
@comments << comment
|
data/lib/gettext/version.rb
CHANGED
Binary file
|
data/po/ja/gettext.po
CHANGED
@@ -7,7 +7,7 @@ msgid ""
|
|
7
7
|
msgstr ""
|
8
8
|
"Project-Id-Version: gettext 2.3.1\n"
|
9
9
|
"Report-Msgid-Bugs-To: \n"
|
10
|
-
"POT-Creation-Date:
|
10
|
+
"POT-Creation-Date: 2013-01-11 15:10+0900\n"
|
11
11
|
"PO-Revision-Date: 2012-10-16 16:20+0900\n"
|
12
12
|
"Last-Translator: Haruka Yoshihara <yoshihara@clear-code.com>\n"
|
13
13
|
"Language-Team: Japanese\n"
|
@@ -38,7 +38,9 @@ msgid "Check these po/pot-files. It may have syntax errors or something wrong."
|
|
38
38
|
msgstr "po/potファイルをチェックしてください。文法エラーもしくはその他のエラーがあるかもしれません。"
|
39
39
|
|
40
40
|
#: ../lib/gettext/tools.rb:188
|
41
|
-
msgid "
|
41
|
+
msgid ""
|
42
|
+
"`%{cmd}' can not be found. \n"
|
43
|
+
"Install GNU Gettext then set PATH or MSGMERGE_PATH correctly."
|
42
44
|
msgstr ""
|
43
45
|
"`%{cmd}'は見つかりませんでした。\n"
|
44
46
|
"GNU Gettextをインストールし、環境変数PATHかMSGMERGE_PATHを正しく設定してください。"
|
@@ -56,19 +58,19 @@ msgid "Generate binary message catalog from textual translation description."
|
|
56
58
|
msgstr "poファイルからバイナリのメッセージカタログファイル(moファイル)を生成します。"
|
57
59
|
|
58
60
|
#: ../lib/gettext/tools/msgfmt.rb:89
|
59
|
-
#: ../lib/gettext/tools/msgmerge.rb:
|
61
|
+
#: ../lib/gettext/tools/msgmerge.rb:488
|
60
62
|
#: ../lib/gettext/tools/xgettext.rb:213
|
61
63
|
msgid "write output to specified file"
|
62
64
|
msgstr "出力ファイルを指定します"
|
63
65
|
|
64
66
|
#: ../lib/gettext/tools/msgfmt.rb:93
|
65
|
-
#: ../lib/gettext/tools/msgmerge.rb:
|
67
|
+
#: ../lib/gettext/tools/msgmerge.rb:499
|
66
68
|
#: ../lib/gettext/tools/xgettext.rb:256
|
67
69
|
msgid "display version information and exit"
|
68
70
|
msgstr "バージョンを表示します"
|
69
71
|
|
70
72
|
#: ../lib/gettext/tools/msgfmt.rb:86 ../lib/gettext/tools/msginit.rb:88
|
71
|
-
#: ../lib/gettext/tools/msgmerge.rb:
|
73
|
+
#: ../lib/gettext/tools/msgmerge.rb:483
|
72
74
|
#: ../lib/gettext/tools/xgettext.rb:210
|
73
75
|
msgid "Specific options:"
|
74
76
|
msgstr "オプション:"
|
@@ -90,7 +92,7 @@ msgid "Use LOCALE as target locale. If LOCALE is not specified, LOCALE is the cu
|
|
90
92
|
msgstr "LOCALEとして指定された値をターゲットのロケールとして扱います。ロケールが指定されていない場合は、ユーザの現在のロケールを使用します。"
|
91
93
|
|
92
94
|
#: ../lib/gettext/tools/msginit.rb:111
|
93
|
-
#: ../lib/gettext/tools/msgmerge.rb:
|
95
|
+
#: ../lib/gettext/tools/msgmerge.rb:494
|
94
96
|
msgid "Display this help and exit"
|
95
97
|
msgstr "このヘルプを表示します"
|
96
98
|
|
@@ -122,19 +124,19 @@ msgstr "あなたのフルネームを入力してください"
|
|
122
124
|
msgid "Please enter your email address"
|
123
125
|
msgstr "あなたのメールアドレスを入力してください"
|
124
126
|
|
125
|
-
#: ../lib/gettext/tools/msgmerge.rb:
|
127
|
+
#: ../lib/gettext/tools/msgmerge.rb:462
|
126
128
|
msgid "definition po is not given."
|
127
129
|
msgstr "poファイルが指定されていません。"
|
128
130
|
|
129
|
-
#: ../lib/gettext/tools/msgmerge.rb:
|
131
|
+
#: ../lib/gettext/tools/msgmerge.rb:464
|
130
132
|
msgid "reference pot is not given."
|
131
133
|
msgstr "potファイルが指定されていません。"
|
132
134
|
|
133
|
-
#: ../lib/gettext/tools/msgmerge.rb:
|
135
|
+
#: ../lib/gettext/tools/msgmerge.rb:472
|
134
136
|
msgid "Usage: %s def.po ref.pot [-o output.pot]"
|
135
137
|
msgstr "使用法: %s def.po ref.pot [-o output.pot]"
|
136
138
|
|
137
|
-
#: ../lib/gettext/tools/msgmerge.rb:
|
139
|
+
#: ../lib/gettext/tools/msgmerge.rb:475
|
138
140
|
msgid "Merges two Uniforum style .po files together. The def.po file is an existing PO file with translations. The ref.pot file is the last created PO file with up-to-date source references. ref.pot is generally created by rgettext."
|
139
141
|
msgstr "2つの.poファイルをマージします。def.poファイルはすでにある翻訳済みのPOファイルです。ref.potは最新のPOファイルです。ref.potは通常xgettextから新たに生成されたものです。"
|
140
142
|
|
@@ -203,15 +205,18 @@ msgid "This message is from hellolib."
|
|
203
205
|
msgstr ""
|
204
206
|
|
205
207
|
#: ../samples/hello.rb:16
|
206
|
-
msgid "
|
208
|
+
msgid ""
|
209
|
+
"Hello World\n"
|
207
210
|
msgstr ""
|
208
211
|
|
209
212
|
#: ../samples/hello2.rb:18
|
210
|
-
msgid "
|
213
|
+
msgid ""
|
214
|
+
"One is %{num}\n"
|
211
215
|
msgstr ""
|
212
216
|
|
213
217
|
#: ../samples/hello2.rb:19
|
214
|
-
msgid "
|
218
|
+
msgid ""
|
219
|
+
"Hello %{world}\n"
|
215
220
|
msgstr ""
|
216
221
|
|
217
222
|
#: ../samples/hello2.rb:19
|
@@ -219,7 +224,10 @@ msgid "World"
|
|
219
224
|
msgstr ""
|
220
225
|
|
221
226
|
#: ../samples/hello_glade2.glade:30
|
222
|
-
msgid "
|
227
|
+
msgid ""
|
228
|
+
"first line\n"
|
229
|
+
"second line\n"
|
230
|
+
"third line"
|
223
231
|
msgstr ""
|
224
232
|
|
225
233
|
#: ../samples/hello_glade2.glade:54
|
@@ -243,8 +251,10 @@ msgid "Hello World"
|
|
243
251
|
msgstr ""
|
244
252
|
|
245
253
|
#: ../samples/hello_plural.rb:19
|
246
|
-
msgid "
|
247
|
-
|
254
|
+
msgid ""
|
255
|
+
"There is an apple.\n"
|
256
|
+
msgid_plural ""
|
257
|
+
"There are %{num} apples.\n"
|
248
258
|
msgstr[0] ""
|
249
259
|
msgstr[1] ""
|
250
260
|
|
@@ -291,7 +301,9 @@ msgid " aaa"
|
|
291
301
|
msgstr ""
|
292
302
|
|
293
303
|
#: ../test/fixtures/_.rb:100
|
294
|
-
msgid "
|
304
|
+
msgid ""
|
305
|
+
"Here document1\n"
|
306
|
+
"Here document2\n"
|
295
307
|
msgstr ""
|
296
308
|
|
297
309
|
#. This is a proper name. See the gettext
|
@@ -317,15 +329,21 @@ msgid "This is a # including string."
|
|
317
329
|
msgstr ""
|
318
330
|
|
319
331
|
#: ../test/fixtures/_.rb:34 ../test/fixtures/N_.rb:14
|
320
|
-
msgid "
|
332
|
+
msgid ""
|
333
|
+
"aaa\n"
|
321
334
|
msgstr ""
|
322
335
|
|
323
336
|
#: ../test/fixtures/_.rb:38 ../test/fixtures/N_.rb:18
|
324
|
-
msgid "
|
337
|
+
msgid ""
|
338
|
+
"bbb\n"
|
339
|
+
"ccc"
|
325
340
|
msgstr ""
|
326
341
|
|
327
342
|
#: ../test/fixtures/_.rb:42 ../test/fixtures/N_.rb:22
|
328
|
-
msgid "
|
343
|
+
msgid ""
|
344
|
+
"bbb\n"
|
345
|
+
"ccc\n"
|
346
|
+
"ddd\n"
|
329
347
|
msgstr ""
|
330
348
|
|
331
349
|
#: ../test/fixtures/_.rb:53 ../test/fixtures/N_.rb:33
|
@@ -348,7 +366,9 @@ msgid "lllmmm"
|
|
348
366
|
msgstr ""
|
349
367
|
|
350
368
|
#: ../test/fixtures/_.rb:84 ../test/fixtures/N_.rb:64
|
351
|
-
msgid "
|
369
|
+
msgid ""
|
370
|
+
"nnn\n"
|
371
|
+
"ooo"
|
352
372
|
msgstr ""
|
353
373
|
|
354
374
|
#: ../test/fixtures/_.rb:88 ../test/fixtures/_.rb:92
|
@@ -368,7 +388,10 @@ msgid "normal text"
|
|
368
388
|
msgstr ""
|
369
389
|
|
370
390
|
#: ../test/fixtures/gladeparser.glade:50
|
371
|
-
msgid "
|
391
|
+
msgid ""
|
392
|
+
"1st line\n"
|
393
|
+
"2nd line\n"
|
394
|
+
"3rd line"
|
372
395
|
msgstr ""
|
373
396
|
|
374
397
|
#: ../test/fixtures/gladeparser.glade:73
|
@@ -376,7 +399,9 @@ msgid "<span color=\"red\" weight=\"bold\" size=\"large\">markup </span>"
|
|
376
399
|
msgstr ""
|
377
400
|
|
378
401
|
#: ../test/fixtures/gladeparser.glade:94
|
379
|
-
msgid "
|
402
|
+
msgid ""
|
403
|
+
"<span color=\"red\">1st line markup </span>\n"
|
404
|
+
"<span color=\"blue\">2nd line markup</span>"
|
380
405
|
msgstr ""
|
381
406
|
|
382
407
|
#: ../test/fixtures/gladeparser.glade:116
|
@@ -426,26 +451,41 @@ msgid "no data"
|
|
426
451
|
msgstr ""
|
427
452
|
|
428
453
|
#: ../test/fixtures/n_.rb:33
|
429
|
-
msgid "
|
430
|
-
|
454
|
+
msgid ""
|
455
|
+
"bbb\n"
|
456
|
+
msgid_plural ""
|
457
|
+
"ccc2\n"
|
458
|
+
"ccc2"
|
431
459
|
msgstr[0] ""
|
432
460
|
msgstr[1] ""
|
433
461
|
|
434
462
|
#: ../test/fixtures/n_.rb:37
|
435
|
-
msgid "
|
436
|
-
|
463
|
+
msgid ""
|
464
|
+
"ddd\n"
|
465
|
+
"ddd"
|
466
|
+
msgid_plural ""
|
467
|
+
"ddd2\n"
|
468
|
+
"ddd2"
|
437
469
|
msgstr[0] ""
|
438
470
|
msgstr[1] ""
|
439
471
|
|
440
472
|
#: ../test/fixtures/n_.rb:42
|
441
|
-
msgid "
|
442
|
-
|
473
|
+
msgid ""
|
474
|
+
"eee\n"
|
475
|
+
"eee\n"
|
476
|
+
msgid_plural ""
|
477
|
+
"eee2\n"
|
478
|
+
"eee2\n"
|
443
479
|
msgstr[0] ""
|
444
480
|
msgstr[1] ""
|
445
481
|
|
446
482
|
#: ../test/fixtures/n_.rb:48
|
447
|
-
msgid "
|
448
|
-
|
483
|
+
msgid ""
|
484
|
+
"ddd\n"
|
485
|
+
"eee\n"
|
486
|
+
msgid_plural ""
|
487
|
+
"ddd\n"
|
488
|
+
"eee2"
|
449
489
|
msgstr[0] ""
|
450
490
|
msgstr[1] ""
|
451
491
|
|
data/src/poparser.ry
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
#
|
5
5
|
# Copyright (C) 2002-2008 Masao Mutoh <mutomasa at gmail.com>
|
6
6
|
# Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com>
|
7
|
-
# Copyright (C) 2012 Haruka Yoshihara <yoshihara@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.
|
@@ -118,7 +118,16 @@ end
|
|
118
118
|
|
119
119
|
---- header
|
120
120
|
require "gettext/tools/po"
|
121
|
-
|
121
|
+
|
122
|
+
# For suppressing warning. PoData is deprecated and will be removed.
|
123
|
+
module GetText
|
124
|
+
module Tools
|
125
|
+
class MsgMerge
|
126
|
+
class PoData
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
122
131
|
---- inner
|
123
132
|
if GetText.respond_to?(:bindtextdomain)
|
124
133
|
include GetText
|
@@ -282,11 +291,6 @@ require "gettext/tools/msgmerge"
|
|
282
291
|
comment
|
283
292
|
end
|
284
293
|
|
285
|
-
TRANSLATOR_COMMENT_MARK = "# "
|
286
|
-
EXTRACTED_COMMENT_MARK = "#."
|
287
|
-
FLAG_MARK = "#,"
|
288
|
-
PREVIOUS_MSGID_COMMENT_MARK = "#|"
|
289
|
-
REFERENCE_COMMENT_MARK = "#:"
|
290
294
|
def on_comment(comment)
|
291
295
|
@fuzzy = true if (/fuzzy/ =~ comment)
|
292
296
|
if @data.instance_of?(PO) or
|
@@ -297,15 +301,15 @@ require "gettext/tools/msgmerge"
|
|
297
301
|
mark = $1
|
298
302
|
content = $2
|
299
303
|
case mark
|
300
|
-
when TRANSLATOR_COMMENT_MARK
|
304
|
+
when POEntry::TRANSLATOR_COMMENT_MARK
|
301
305
|
@translator_comments << content
|
302
|
-
when EXTRACTED_COMMENT_MARK
|
306
|
+
when POEntry::EXTRACTED_COMMENT_MARK
|
303
307
|
@extracted_comments << content
|
304
|
-
when REFERENCE_COMMENT_MARK
|
308
|
+
when POEntry::REFERENCE_COMMENT_MARK
|
305
309
|
@references << content
|
306
|
-
when FLAG_MARK
|
310
|
+
when POEntry::FLAG_MARK
|
307
311
|
@flag << content
|
308
|
-
when
|
312
|
+
when POEntry::PREVIOUS_COMMENT_MARK
|
309
313
|
@previous << content
|
310
314
|
else
|
311
315
|
@comments << comment
|
data/test/tools/test_msgmerge.rb
CHANGED
@@ -332,45 +332,6 @@ EOE
|
|
332
332
|
assert_equal("salut", merged_po["hello"].msgstr)
|
333
333
|
end
|
334
334
|
|
335
|
-
def test_similar_msgstr_for_fuzzy
|
336
|
-
@po["helol"] = "bonjour"
|
337
|
-
@pot["hello"] = ""
|
338
|
-
merged_po = @merger.merge(@po, @pot)
|
339
|
-
|
340
|
-
assert_false(merged_po.has_key?("helol"))
|
341
|
-
assert_true(merged_po.has_key?("hello"))
|
342
|
-
assert_equal("bonjour", merged_po["hello"].msgstr)
|
343
|
-
assert_equal("fuzzy", merged_po["hello"].flag)
|
344
|
-
end
|
345
|
-
|
346
|
-
def test_nonexistent_msgctxt
|
347
|
-
@po["normal", "hello"] = generate_entry(:msgctxt => "normal",
|
348
|
-
:msgid => "hello",
|
349
|
-
:msgstr => "salut")
|
350
|
-
@pot["hello"] = generate_entry(:msgid => "hello",
|
351
|
-
:msgstr => "")
|
352
|
-
merged_po = @merger.merge(@po, @pot)
|
353
|
-
|
354
|
-
assert_false(merged_po.has_key?("normal", "hello"))
|
355
|
-
assert_true(merged_po.has_key?("hello"))
|
356
|
-
assert_equal("salut", merged_po["hello"].msgstr)
|
357
|
-
assert_equal("fuzzy", merged_po["hello"].flag)
|
358
|
-
end
|
359
|
-
|
360
|
-
def test_msgid_plural
|
361
|
-
@po["he"] = generate_entry(:msgid => "he",
|
362
|
-
:msgid_plural => "thye",
|
363
|
-
:msgstr => "il\000ils")
|
364
|
-
@pot["he"] = generate_entry(:msgid => "he",
|
365
|
-
:msgid_plural => "they",
|
366
|
-
:msgstr => "")
|
367
|
-
merged_po = @merger.merge(@po, @pot)
|
368
|
-
|
369
|
-
assert_equal("il\000ils", merged_po["he"].msgstr)
|
370
|
-
assert_equal("they", merged_po["he"].msgid_plural)
|
371
|
-
assert_equal("fuzzy", merged_po["he"].flag)
|
372
|
-
end
|
373
|
-
|
374
335
|
def test_translator_comment
|
375
336
|
@po["hello"] = generate_entry(:msgid => "hello",
|
376
337
|
:msgstr => "bonjour",
|
@@ -429,19 +390,6 @@ EOE
|
|
429
390
|
assert_equal("no-c-format", merged_po["hello"].flag)
|
430
391
|
end
|
431
392
|
|
432
|
-
def test_fuzzy_flag
|
433
|
-
@po["hello"] = generate_entry(:msgid => "hello",
|
434
|
-
:msgstr => "bonjuor",
|
435
|
-
:flag => "fuzzy")
|
436
|
-
|
437
|
-
@pot["hello"] = generate_entry(:msgid => "hello",
|
438
|
-
:msgstr => "")
|
439
|
-
|
440
|
-
merged_po = @merger.merge(@po, @pot)
|
441
|
-
assert_equal("bonjuor", merged_po["hello"].msgstr)
|
442
|
-
assert_equal("fuzzy", merged_po["hello"].flag)
|
443
|
-
end
|
444
|
-
|
445
393
|
def test_previous
|
446
394
|
@po["hello"] = generate_entry(:msgid => "hello",
|
447
395
|
:msgstr => "bonjour",
|
@@ -455,37 +403,103 @@ EOE
|
|
455
403
|
assert_equal(nil, merged_po["hello"].previous)
|
456
404
|
end
|
457
405
|
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
406
|
+
class TestAddNoFuzzy < self
|
407
|
+
def test_add_to_nontranslated_entry
|
408
|
+
@po["helol"] = generate_entry(:msgid => "helol",
|
409
|
+
:msgstr => nil)
|
410
|
+
@pot["hello"] = generate_entry(:msgid => "hello",
|
411
|
+
:msgstr => nil)
|
412
|
+
merged_po = @merger.merge(@po, @pot)
|
413
|
+
assert_true(merged_po.has_key?("hello"))
|
414
|
+
assert_nil(merged_po["hello"].flag)
|
415
|
+
end
|
462
416
|
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
417
|
+
def test_fuzzy_header
|
418
|
+
@po[""] = generate_entry(:msgid => "",
|
419
|
+
:msgstr => "header\nentry",
|
420
|
+
:translator_comment => "header comment")
|
467
421
|
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
422
|
+
@pot[""] = generate_entry(:msgid => "",
|
423
|
+
:msgstr => "uninitialized\ncomment",
|
424
|
+
:translator_comment => "uninitialized comment",
|
425
|
+
:flag => "fuzzy")
|
426
|
+
|
427
|
+
merged_po = @merger.merge(@po, @pot)
|
428
|
+
assert_equal("header\nentry", merged_po[""].msgstr)
|
429
|
+
assert_equal("header comment", merged_po[""].translator_comment)
|
430
|
+
assert_equal(nil, merged_po[""].flag)
|
431
|
+
end
|
432
|
+
|
433
|
+
def test_fuzzy_header_including_pot_creation_date
|
434
|
+
creation_date_mark = "POT-Creation-Date: "
|
435
|
+
po_creation_date = "#{creation_date_mark}2012-11-15 08:15+0900"
|
436
|
+
pot_creation_date = "#{creation_date_mark}2012-11-20 14:15+0900"
|
437
|
+
@po[""] = generate_entry(:msgid => "",
|
438
|
+
:msgstr => po_creation_date,
|
439
|
+
:translator_comment => "header comment")
|
440
|
+
|
441
|
+
@pot[""] = generate_entry(:msgid => "",
|
442
|
+
:msgstr => pot_creation_date,
|
443
|
+
:translator_comment => "header comment",
|
444
|
+
:flag => "fuzzy")
|
445
|
+
|
446
|
+
merged_po = @merger.merge(@po, @pot)
|
447
|
+
assert_equal(pot_creation_date, merged_po[""].msgstr)
|
448
|
+
end
|
472
449
|
end
|
473
450
|
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
451
|
+
class TestAddFuzzy < self
|
452
|
+
def test_nonexistent_msgctxt
|
453
|
+
@po["normal", "hello"] = generate_entry(:msgctxt => "normal",
|
454
|
+
:msgid => "hello",
|
455
|
+
:msgstr => "salut")
|
456
|
+
@pot["hello"] = generate_entry(:msgid => "hello",
|
457
|
+
:msgstr => "")
|
458
|
+
merged_po = @merger.merge(@po, @pot)
|
459
|
+
|
460
|
+
assert_false(merged_po.has_key?("normal", "hello"))
|
461
|
+
assert_true(merged_po.has_key?("hello"))
|
462
|
+
assert_equal("salut", merged_po["hello"].msgstr)
|
463
|
+
assert_equal("fuzzy", merged_po["hello"].flag)
|
464
|
+
end
|
481
465
|
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
466
|
+
def test_msgid_plural
|
467
|
+
@po["he"] = generate_entry(:msgid => "he",
|
468
|
+
:msgid_plural => "thye",
|
469
|
+
:msgstr => "il\000ils")
|
470
|
+
@pot["he"] = generate_entry(:msgid => "he",
|
471
|
+
:msgid_plural => "they",
|
472
|
+
:msgstr => "")
|
473
|
+
merged_po = @merger.merge(@po, @pot)
|
474
|
+
|
475
|
+
assert_equal("il\000ils", merged_po["he"].msgstr)
|
476
|
+
assert_equal("they", merged_po["he"].msgid_plural)
|
477
|
+
assert_equal("fuzzy", merged_po["he"].flag)
|
478
|
+
end
|
486
479
|
|
487
|
-
|
488
|
-
|
480
|
+
def test_fuzzy_matching_entry
|
481
|
+
@po["helol"] = "bonjour"
|
482
|
+
@pot["hello"] = ""
|
483
|
+
merged_po = @merger.merge(@po, @pot)
|
484
|
+
|
485
|
+
assert_false(merged_po.has_key?("helol"))
|
486
|
+
assert_true(merged_po.has_key?("hello"))
|
487
|
+
assert_equal("bonjour", merged_po["hello"].msgstr)
|
488
|
+
assert_equal("fuzzy", merged_po["hello"].flag)
|
489
|
+
end
|
490
|
+
|
491
|
+
def test_merged_entry_from_fuzzy_entry
|
492
|
+
@po["hello"] = generate_entry(:msgid => "hello",
|
493
|
+
:msgstr => "bonjuor",
|
494
|
+
:flag => "fuzzy")
|
495
|
+
|
496
|
+
@pot["hello"] = generate_entry(:msgid => "hello",
|
497
|
+
:msgstr => "")
|
498
|
+
|
499
|
+
merged_po = @merger.merge(@po, @pot)
|
500
|
+
assert_equal("bonjuor", merged_po["hello"].msgstr)
|
501
|
+
assert_equal("fuzzy", merged_po["hello"].flag)
|
502
|
+
end
|
489
503
|
end
|
490
504
|
|
491
505
|
def test_obsolete_entry
|
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: 2.3.
|
4
|
+
version: 2.3.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2013-01-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: locale
|
@@ -966,7 +966,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
966
966
|
version: '0'
|
967
967
|
segments:
|
968
968
|
- 0
|
969
|
-
hash:
|
969
|
+
hash: 756291154754834137
|
970
970
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
971
971
|
none: false
|
972
972
|
requirements:
|
@@ -975,7 +975,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
975
975
|
version: '0'
|
976
976
|
segments:
|
977
977
|
- 0
|
978
|
-
hash:
|
978
|
+
hash: 756291154754834137
|
979
979
|
requirements: []
|
980
980
|
rubyforge_project: gettext
|
981
981
|
rubygems_version: 1.8.23
|