gettext 2.3.0 → 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +6 -0
- data/Rakefile +7 -6
- data/doc/text/news.md +51 -2
- data/gettext.gemspec +1 -0
- data/lib/gettext/runtime/locale_path.rb +0 -1
- data/lib/gettext/runtime/mofile.rb +8 -2
- data/lib/gettext/runtime/textdomain.rb +19 -21
- data/lib/gettext/runtime/textdomain_manager.rb +0 -1
- data/lib/gettext/tools/msginit.rb +19 -9
- data/lib/gettext/tools/msgmerge.rb +28 -15
- data/lib/gettext/tools/parser/erb.rb +25 -5
- data/lib/gettext/tools/parser/glade.rb +4 -3
- data/lib/gettext/tools/parser/ruby.rb +23 -5
- data/lib/gettext/tools/poparser.rb +2 -1
- data/lib/gettext/tools/xgettext.rb +187 -136
- data/lib/gettext/version.rb +1 -1
- data/po/ja/gettext.po +82 -41
- data/samples/cgi/locale/bg/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/bs/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/ca/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/cs/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/de/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/el/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/eo/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/es/LC_MESSAGES/main.mo +0 -0
- data/samples/po/hello.pot +3 -3
- data/samples/po/hello2.pot +3 -3
- data/samples/po/hello_glade2.pot +3 -3
- data/samples/po/hello_gtk2.pot +3 -3
- data/samples/po/hello_noop.pot +3 -3
- data/samples/po/hello_plural.pot +3 -3
- data/samples/po/hello_tk.pot +3 -3
- data/src/poparser.ry +1 -0
- data/test/fixtures/_.rb +4 -4
- data/test/fixtures/{erb.rhtml → erb/ascii.rhtml} +0 -0
- data/test/fixtures/{erb.rxml → erb/ascii.rxml} +0 -0
- data/test/fixtures/erb/non_ascii.rhtml +13 -0
- data/test/fixtures/untranslated.rb +12 -0
- data/test/gettext-test-utils.rb +23 -0
- data/test/locale/ja/LC_MESSAGES/untranslated.mo +0 -0
- data/test/parser/test_ruby.rb +48 -1
- data/test/po/_.pot +4 -4
- data/test/po/ascii.pot +23 -0
- data/test/po/backslash.pot +3 -3
- data/test/po/ja/untranslated.po +22 -0
- data/test/po/no_exist_msgid.pot +20 -0
- data/test/po/non_ascii.pot +3 -3
- data/test/po/not_existed_msgid.pot +20 -0
- data/test/po/np_.pot +3 -3
- data/test/po/ns_.pot +3 -3
- data/test/po/p_.pot +3 -3
- data/test/po/s_.pot +3 -3
- data/test/po/untranslated.pot +23 -0
- data/test/run-test.rb +1 -1
- data/test/test_gettext.rb +2 -2
- data/test/test_mofile.rb +10 -0
- data/test/test_parser.rb +45 -19
- data/test/test_po_parser.rb +14 -1
- data/test/tools/test_msginit.rb +52 -36
- data/test/tools/test_msgmerge.rb +44 -6
- data/test/tools/test_xgettext.rb +203 -5
- metadata +143 -146
- data/po/de/gettext.po +0 -668
- data/po/de/gettext.po.bak +0 -589
- data/po/el/gettext.po +0 -571
- data/po/fr/gettext.po +0 -589
- data/po/gettext.pot +0 -638
- data/po/gettext.pot~ +0 -638
- data/po/it/gettext.po +0 -589
- data/po/uk/gettext.po +0 -571
- data/test/locale/ja/LC_MESSAGES/npgettext.mo +0 -0
- data/test/locale/ja/LC_MESSAGES/nsgettext.mo +0 -0
- data/test/locale/ja/LC_MESSAGES/pgettext.mo +0 -0
- data/test/locale/ja/LC_MESSAGES/sgettext.mo +0 -0
data/test/run-test.rb
CHANGED
data/test/test_gettext.rb
CHANGED
@@ -52,7 +52,7 @@ class TestGetText < Test::Unit::TestCase
|
|
52
52
|
set_locale("ja")
|
53
53
|
assert_equal("JAPANESE", _("LANGUAGE")) # influence of previous line
|
54
54
|
assert_equal("japanese", test.test)
|
55
|
-
|
55
|
+
end
|
56
56
|
|
57
57
|
def test_no_msgstr
|
58
58
|
bindtextdomain("test1", :path => "locale")
|
@@ -77,7 +77,7 @@ EOH
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def test_gettext
|
80
|
-
test =
|
80
|
+
test = MessageFixture.new
|
81
81
|
assert_equal("AAA", test.test_1)
|
82
82
|
assert_equal("AAA\n", test.test_2)
|
83
83
|
assert_equal("BBB\nCCC", test.test_3)
|
data/test/test_mofile.rb
CHANGED
@@ -3,6 +3,16 @@
|
|
3
3
|
require 'gettext/runtime/mofile'
|
4
4
|
|
5
5
|
class TestMoFile < Test::Unit::TestCase
|
6
|
+
def test_not_exist_msgid
|
7
|
+
mo = load_mo("_.mo")
|
8
|
+
assert_equal(nil, mo["notexistent"])
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_untranslated
|
12
|
+
mo = load_mo("untranslated.mo")
|
13
|
+
assert_equal(nil, mo["untranslated"])
|
14
|
+
end
|
15
|
+
|
6
16
|
def test_non_ascii
|
7
17
|
mo = load_mo("non_ascii.mo")
|
8
18
|
assert_equal("Hello in Japanese", mo["こんにちは"])
|
data/test/test_parser.rb
CHANGED
@@ -21,6 +21,7 @@
|
|
21
21
|
# You should have received a copy of the GNU Lesser General Public License
|
22
22
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
23
23
|
|
24
|
+
require "tempfile"
|
24
25
|
require 'gettext/tools/parser/ruby'
|
25
26
|
require 'gettext/tools/parser/glade'
|
26
27
|
require 'gettext/tools/parser/erb'
|
@@ -51,8 +52,8 @@ class TestGetTextParser < Test::Unit::TestCase
|
|
51
52
|
assert_target "\\taaa", ['fixtures/_.rb:96']
|
52
53
|
assert_target "Here document1\\nHere document2\\n", ['fixtures/_.rb:100']
|
53
54
|
assert_target "Francois Pinard", ['fixtures/_.rb:119'] do |t|
|
54
|
-
assert_match
|
55
|
-
assert_match
|
55
|
+
assert_match(/proper name/, t.comment)
|
56
|
+
assert_match(/Pronunciation/, t.comment)
|
56
57
|
end
|
57
58
|
|
58
59
|
assert_target("No TRANSLATORS comment", ["fixtures/_.rb:122"]) do |t|
|
@@ -128,28 +129,53 @@ class TestGetTextParser < Test::Unit::TestCase
|
|
128
129
|
assert_equal(['duplicated', 'fixtures/gladeparser.glade:137', 'fixtures/gladeparser.glade:158'], ary[6])
|
129
130
|
end
|
130
131
|
|
131
|
-
|
132
|
-
|
132
|
+
class TestErbParser < self
|
133
|
+
include GetTextTestUtils
|
133
134
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
135
|
+
def test_detect_encoding
|
136
|
+
need_encoding
|
137
|
+
|
138
|
+
euc_file = Tempfile.new("euc-jp.rhtml")
|
139
|
+
euc_file.open
|
140
|
+
euc_file.puts("<%#-*- coding: euc-jp -*-%>")
|
141
|
+
euc_file.close
|
142
|
+
|
143
|
+
erb_source = ERB.new(File.read(euc_file.path)).src
|
144
|
+
encoding = GetText::ErbParser.detect_encoding(erb_source)
|
145
|
+
|
146
|
+
assert_equal("EUC-JP", encoding)
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_ascii
|
150
|
+
@ary = GetText::ErbParser.parse('fixtures/erb/ascii.rhtml')
|
151
|
+
|
152
|
+
assert_target 'aaa', ['fixtures/erb/ascii.rhtml:8']
|
153
|
+
assert_target 'aaa\n', ['fixtures/erb/ascii.rhtml:11']
|
154
|
+
assert_target 'bbb', ['fixtures/erb/ascii.rhtml:12']
|
155
|
+
assert_plural_target "ccc1", "ccc2", ['fixtures/erb/ascii.rhtml:13']
|
156
|
+
end
|
157
|
+
|
158
|
+
def test_non_ascii
|
159
|
+
fixture_path = "fixtures/erb/non_ascii.rhtml"
|
160
|
+
@ary = GetText::ErbParser.parse(fixture_path)
|
161
|
+
|
162
|
+
assert_target('わたし', ["#{fixture_path}:11"])
|
163
|
+
end
|
138
164
|
end
|
139
165
|
|
140
166
|
def test_xgettext_parse
|
141
167
|
GetText::ErbParser.init(:extnames => ['.rhtml', '.rxml'])
|
142
|
-
@ary = @xgettext.parse(['fixtures/erb.rhtml'])
|
143
|
-
assert_target 'aaa', ['fixtures/erb.rhtml:8']
|
144
|
-
assert_target 'aaa\n', ['fixtures/erb.rhtml:11']
|
145
|
-
assert_target 'bbb', ['fixtures/erb.rhtml:12']
|
146
|
-
assert_plural_target "ccc1", "ccc2", ['fixtures/erb.rhtml:13']
|
147
|
-
|
148
|
-
@ary = @xgettext.parse(['fixtures/erb.rxml'])
|
149
|
-
assert_target 'aaa', ['fixtures/erb.rxml:9']
|
150
|
-
assert_target 'aaa\n', ['fixtures/erb.rxml:12']
|
151
|
-
assert_target 'bbb', ['fixtures/erb.rxml:13']
|
152
|
-
assert_plural_target "ccc1", "ccc2", ['fixtures/erb.rxml:14']
|
168
|
+
@ary = @xgettext.parse(['fixtures/erb/ascii.rhtml'])
|
169
|
+
assert_target 'aaa', ['fixtures/erb/ascii.rhtml:8']
|
170
|
+
assert_target 'aaa\n', ['fixtures/erb/ascii.rhtml:11']
|
171
|
+
assert_target 'bbb', ['fixtures/erb/ascii.rhtml:12']
|
172
|
+
assert_plural_target "ccc1", "ccc2", ['fixtures/erb/ascii.rhtml:13']
|
173
|
+
|
174
|
+
@ary = @xgettext.parse(['fixtures/erb/ascii.rxml'])
|
175
|
+
assert_target 'aaa', ['fixtures/erb/ascii.rxml:9']
|
176
|
+
assert_target 'aaa\n', ['fixtures/erb/ascii.rxml:12']
|
177
|
+
assert_target 'bbb', ['fixtures/erb/ascii.rxml:13']
|
178
|
+
assert_plural_target "ccc1", "ccc2", ['fixtures/erb/ascii.rxml:14']
|
153
179
|
|
154
180
|
@ary = @xgettext.parse(['fixtures/n_.rb'])
|
155
181
|
assert_plural_target "ooo", "ppp", ['fixtures/n_.rb:85', 'fixtures/n_.rb:86']
|
data/test/test_po_parser.rb
CHANGED
@@ -28,7 +28,20 @@ msgstr ""
|
|
28
28
|
EOP
|
29
29
|
messages = parse_po_file(po_file)
|
30
30
|
|
31
|
-
assert_equal(
|
31
|
+
assert_equal(nil, messages["Hello"])
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_empty_msgstr_for_msgid_plural
|
35
|
+
po_file = create_po_file(<<-EOP)
|
36
|
+
msgid "He"
|
37
|
+
msgid_plural "They"
|
38
|
+
msgstr[0] ""
|
39
|
+
msgstr[1] ""
|
40
|
+
EOP
|
41
|
+
messages = parse_po_file(po_file)
|
42
|
+
|
43
|
+
assert_true(messages.has_key?("He\000They"))
|
44
|
+
assert_equal(nil, messages["He\000They"])
|
32
45
|
end
|
33
46
|
|
34
47
|
private
|
data/test/tools/test_msginit.rb
CHANGED
@@ -26,9 +26,14 @@ class TestToolsMsgInit < Test::Unit::TestCase
|
|
26
26
|
stub(@msginit).read_translator_full_name {translator_full_name}
|
27
27
|
stub(@msginit).read_translator_mail {translator_mail}
|
28
28
|
|
29
|
+
@year = "2012"
|
30
|
+
@po_revision_date = "2012-09-11 13:19+0900"
|
31
|
+
@pot_create_date = "2012-08-24 11:35+0900"
|
32
|
+
|
33
|
+
stub(@msginit).year {@year}
|
34
|
+
stub(@msginit).revision_date {@po_revision_date}
|
35
|
+
|
29
36
|
Locale.current = "ja_JP.UTF-8"
|
30
|
-
@pot_create_date = "2012-08-24 11:35+0900"
|
31
|
-
@po_revision_date = Time.now.strftime("%Y-%m-%d %H:%M%z")
|
32
37
|
end
|
33
38
|
|
34
39
|
def test_all_options
|
@@ -43,7 +48,7 @@ class TestToolsMsgInit < Test::Unit::TestCase
|
|
43
48
|
"--output", po_file_path,
|
44
49
|
"--locale", locale)
|
45
50
|
|
46
|
-
actual_po_header =
|
51
|
+
actual_po_header = File.read(po_file_path)
|
47
52
|
expected_po_header = po_header(locale, language)
|
48
53
|
assert_equal(expected_po_header, actual_po_header)
|
49
54
|
end
|
@@ -59,7 +64,7 @@ class TestToolsMsgInit < Test::Unit::TestCase
|
|
59
64
|
|
60
65
|
@msginit.run("--locale", locale)
|
61
66
|
|
62
|
-
actual_po_header =
|
67
|
+
actual_po_header = File.read(po_file_path)
|
63
68
|
expected_po_header = po_header(locale, language)
|
64
69
|
assert_equal(expected_po_header, actual_po_header)
|
65
70
|
end
|
@@ -76,7 +81,7 @@ class TestToolsMsgInit < Test::Unit::TestCase
|
|
76
81
|
|
77
82
|
@msginit.run("--locale", locale)
|
78
83
|
|
79
|
-
actual_po_header =
|
84
|
+
actual_po_header = File.read(po_file_path)
|
80
85
|
expected_po_header = po_header(locale, language)
|
81
86
|
assert_equal(expected_po_header, actual_po_header)
|
82
87
|
end
|
@@ -94,7 +99,7 @@ class TestToolsMsgInit < Test::Unit::TestCase
|
|
94
99
|
|
95
100
|
@msginit.run("--locale", "#{locale}.#{charset}")
|
96
101
|
|
97
|
-
actual_po_header =
|
102
|
+
actual_po_header = File.read(po_file_path)
|
98
103
|
expected_po_header = po_header(locale, language)
|
99
104
|
assert_equal(expected_po_header, actual_po_header)
|
100
105
|
end
|
@@ -111,7 +116,7 @@ class TestToolsMsgInit < Test::Unit::TestCase
|
|
111
116
|
|
112
117
|
@msginit.run("--input", pot_file_path, "--output", po_file_path)
|
113
118
|
|
114
|
-
actual_po_header =
|
119
|
+
actual_po_header = File.read(po_file_path)
|
115
120
|
expected_po_header = po_header(locale, language)
|
116
121
|
assert_equal(expected_po_header, actual_po_header)
|
117
122
|
end
|
@@ -128,7 +133,7 @@ class TestToolsMsgInit < Test::Unit::TestCase
|
|
128
133
|
|
129
134
|
@msginit.run("--input", pot_file_path)
|
130
135
|
|
131
|
-
actual_po_header =
|
136
|
+
actual_po_header = File.read(po_file_path)
|
132
137
|
expected_po_header = po_header(locale, language)
|
133
138
|
assert_equal(expected_po_header, actual_po_header)
|
134
139
|
end
|
@@ -145,7 +150,7 @@ class TestToolsMsgInit < Test::Unit::TestCase
|
|
145
150
|
|
146
151
|
@msginit.run
|
147
152
|
|
148
|
-
actual_po_header =
|
153
|
+
actual_po_header = File.read(po_file_path)
|
149
154
|
expected_po_header = po_header(locale, language)
|
150
155
|
assert_equal(expected_po_header, actual_po_header)
|
151
156
|
end
|
@@ -165,7 +170,7 @@ class TestToolsMsgInit < Test::Unit::TestCase
|
|
165
170
|
|
166
171
|
@msginit.run
|
167
172
|
|
168
|
-
actual_po_header =
|
173
|
+
actual_po_header = File.read(po_file_path)
|
169
174
|
expected_po_header = no_translator_po_header(locale, language)
|
170
175
|
assert_equal(expected_po_header, actual_po_header)
|
171
176
|
end
|
@@ -184,7 +189,7 @@ class TestToolsMsgInit < Test::Unit::TestCase
|
|
184
189
|
|
185
190
|
@msginit.run
|
186
191
|
|
187
|
-
actual_po_header =
|
192
|
+
actual_po_header = File.read(po_file_path)
|
188
193
|
expected_po_header = no_translator_po_header(locale, language)
|
189
194
|
assert_equal(expected_po_header, actual_po_header)
|
190
195
|
end
|
@@ -203,7 +208,7 @@ class TestToolsMsgInit < Test::Unit::TestCase
|
|
203
208
|
|
204
209
|
@msginit.run
|
205
210
|
|
206
|
-
actual_po_header =
|
211
|
+
actual_po_header = File.read(po_file_path)
|
207
212
|
expected_po_header = no_translator_po_header(locale, language)
|
208
213
|
assert_equal(expected_po_header, actual_po_header)
|
209
214
|
end
|
@@ -215,7 +220,7 @@ class TestToolsMsgInit < Test::Unit::TestCase
|
|
215
220
|
Dir.chdir(dir) do
|
216
221
|
pot_file_name = "test.pot"
|
217
222
|
options = {:package_name => "test-package"}
|
218
|
-
|
223
|
+
create_pot_file(pot_file_name, options)
|
219
224
|
locale = current_locale
|
220
225
|
language = current_language
|
221
226
|
po_file_path = "#{locale}.po"
|
@@ -223,11 +228,29 @@ class TestToolsMsgInit < Test::Unit::TestCase
|
|
223
228
|
@msginit.run("--input", pot_file_name)
|
224
229
|
|
225
230
|
expected_po_header = po_header(locale, language, options)
|
226
|
-
actual_po_header =
|
231
|
+
actual_po_header = File.read(po_file_path)
|
227
232
|
|
228
233
|
assert_equal(expected_po_header, actual_po_header)
|
229
234
|
end
|
230
235
|
end
|
236
|
+
|
237
|
+
def test_no_plural_forms
|
238
|
+
Dir.mktmpdir do |dir|
|
239
|
+
Dir.chdir(dir) do
|
240
|
+
options = {:have_plural_forms => false}
|
241
|
+
create_pot_file("test.pot", options)
|
242
|
+
locale = current_locale
|
243
|
+
language = current_language
|
244
|
+
po_file_path = "#{locale}.po"
|
245
|
+
|
246
|
+
@msginit.run
|
247
|
+
|
248
|
+
actual_po_header = File.read(po_file_path)
|
249
|
+
expected_po_header = po_header(locale, language)
|
250
|
+
assert_equal(expected_po_header, actual_po_header)
|
251
|
+
end
|
252
|
+
end
|
253
|
+
end
|
231
254
|
end
|
232
255
|
|
233
256
|
private
|
@@ -256,7 +279,8 @@ class TestToolsMsgInit < Test::Unit::TestCase
|
|
256
279
|
|
257
280
|
def pot_header(options)
|
258
281
|
package_name = options[:package_name] || default_package_name
|
259
|
-
|
282
|
+
have_plural_forms = options[:have_plural_forms] || true
|
283
|
+
header = <<EOF
|
260
284
|
# SOME DESCRIPTIVE TITLE.
|
261
285
|
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
262
286
|
# This file is distributed under the same license as the PACKAGE package.
|
@@ -274,21 +298,11 @@ msgstr ""
|
|
274
298
|
"MIME-Version: 1.0\\n"
|
275
299
|
"Content-Type: text/plain; charset=UTF-8\\n"
|
276
300
|
"Content-Transfer-Encoding: 8bit\\n"
|
277
|
-
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\\n"
|
278
301
|
EOF
|
279
|
-
|
280
|
-
|
281
|
-
def normalize_po_header(po_file_path)
|
282
|
-
po_file = ""
|
283
|
-
File.open(po_file_path) do |file|
|
284
|
-
po_file = file.read
|
302
|
+
if have_plural_forms
|
303
|
+
header << "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\\n"
|
285
304
|
end
|
286
|
-
|
287
|
-
po_file = po_file.gsub(/#{Regexp.escape(@pot_create_date)}/,
|
288
|
-
"XXXX-XX-XX XX:XX+XXXX")
|
289
|
-
po_file = po_file.gsub(/#{Regexp.escape(@po_revision_date)}/,
|
290
|
-
"YYYY-YY-YY YY:YY+YYYY")
|
291
|
-
po_file.gsub(/#{Time.now.year}/, "YEAR")
|
305
|
+
header
|
292
306
|
end
|
293
307
|
|
294
308
|
def po_header(locale, language, options=nil)
|
@@ -301,15 +315,15 @@ EOF
|
|
301
315
|
|
302
316
|
<<EOF
|
303
317
|
# #{language_name} translations for #{package_name} package.
|
304
|
-
# Copyright (C)
|
318
|
+
# Copyright (C) #{@year} THE PACKAGE'S COPYRIGHT HOLDER
|
305
319
|
# This file is distributed under the same license as the PACKAGE package.
|
306
|
-
# #{full_name} <#{mail}>,
|
320
|
+
# #{full_name} <#{mail}>, #{@year}.
|
307
321
|
#
|
308
322
|
msgid ""
|
309
323
|
msgstr ""
|
310
324
|
"Project-Id-Version: #{package_name} VERSION\\n"
|
311
|
-
"POT-Creation-Date:
|
312
|
-
"PO-Revision-Date:
|
325
|
+
"POT-Creation-Date: #{@pot_create_date}\\n"
|
326
|
+
"PO-Revision-Date: #{@po_revision_date}\\n"
|
313
327
|
"Last-Translator: #{full_name} <#{mail}>\\n"
|
314
328
|
"Language: #{locale}\\n"
|
315
329
|
"Language-Team: #{language_name}\\n"
|
@@ -317,6 +331,7 @@ msgstr ""
|
|
317
331
|
"Content-Type: text/plain; charset=UTF-8\\n"
|
318
332
|
"Content-Transfer-Encoding: 8bit\\n"
|
319
333
|
"Plural-Forms: #{plural_forms}\\n"
|
334
|
+
|
320
335
|
EOF
|
321
336
|
end
|
322
337
|
|
@@ -330,15 +345,15 @@ EOF
|
|
330
345
|
|
331
346
|
<<EOF
|
332
347
|
# #{language_name} translations for PACKAGE package.
|
333
|
-
# Copyright (C)
|
348
|
+
# Copyright (C) #{@year} THE PACKAGE'S COPYRIGHT HOLDER
|
334
349
|
# This file is distributed under the same license as the PACKAGE package.
|
335
|
-
# FIRST AUTHOR <EMAIL@ADDRESS>,
|
350
|
+
# FIRST AUTHOR <EMAIL@ADDRESS>, #{@year}.
|
336
351
|
#
|
337
352
|
msgid ""
|
338
353
|
msgstr ""
|
339
354
|
"Project-Id-Version: PACKAGE VERSION\\n"
|
340
|
-
"POT-Creation-Date:
|
341
|
-
"PO-Revision-Date:
|
355
|
+
"POT-Creation-Date: #{@pot_create_date}\\n"
|
356
|
+
"PO-Revision-Date: #{@po_revision_date}\\n"
|
342
357
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n"
|
343
358
|
"Language: #{locale}\\n"
|
344
359
|
"Language-Team: #{language_name}\\n"
|
@@ -346,6 +361,7 @@ msgstr ""
|
|
346
361
|
"Content-Type: text/plain; charset=UTF-8\\n"
|
347
362
|
"Content-Transfer-Encoding: 8bit\\n"
|
348
363
|
"Plural-Forms: #{plural_forms}\\n"
|
364
|
+
|
349
365
|
EOF
|
350
366
|
end
|
351
367
|
end
|
data/test/tools/test_msgmerge.rb
CHANGED
@@ -37,6 +37,7 @@ class TestToolsMsgMerge < Test::Unit::TestCase
|
|
37
37
|
msgid \"\"
|
38
38
|
msgstr \"\"
|
39
39
|
\"#{header_entry}\\n\"
|
40
|
+
|
40
41
|
#{comment}
|
41
42
|
msgid \"#{msgid}\"
|
42
43
|
msgstr \"#{msgstr}\"
|
@@ -66,6 +67,7 @@ EOC
|
|
66
67
|
msgid \"\"
|
67
68
|
msgstr \"\"
|
68
69
|
\"#{header_entry}\\n\"
|
70
|
+
|
69
71
|
#{obsolete_comment}
|
70
72
|
EOP
|
71
73
|
|
@@ -77,18 +79,53 @@ EOP
|
|
77
79
|
assert_equal(expected_po, po.generate_po)
|
78
80
|
end
|
79
81
|
|
80
|
-
def
|
81
|
-
|
82
|
-
|
83
|
-
@po_data
|
82
|
+
def test_generate_po_msgid_plural_and_empty_msgstr
|
83
|
+
msgid = "Singular message\000Plural message"
|
84
|
+
|
85
|
+
@po_data[""] = "Plural-Forms: nplurals=2; plural=n != 1;\\n"
|
86
|
+
@po_data[msgid] = ""
|
87
|
+
@po_data.set_comment(msgid, "# plural message")
|
88
|
+
actual_po = @po_data.generate_po_entry(msgid)
|
89
|
+
expected_po = <<'EOE'
|
90
|
+
# plural message
|
91
|
+
msgid "Singular message"
|
92
|
+
msgid_plural "Plural message"
|
93
|
+
msgstr[0] ""
|
94
|
+
msgstr[1] ""
|
95
|
+
EOE
|
96
|
+
assert_equal(expected_po, actual_po)
|
97
|
+
end
|
98
|
+
|
99
|
+
class TestGeneratePoEntry < self
|
100
|
+
def test_msgid_plural
|
101
|
+
msgid = "Singular message\000Plural message"
|
102
|
+
|
103
|
+
@po_data[msgid] = "Singular translation\000Plural translation"
|
104
|
+
@po_data.set_comment(msgid, "#plural message")
|
105
|
+
actual_po = @po_data.generate_po_entry(msgid)
|
106
|
+
expected_po = <<'EOE'
|
107
|
+
#plural message
|
108
|
+
msgid "Singular message"
|
109
|
+
msgid_plural "Plural message"
|
110
|
+
msgstr[0] "Singular translation"
|
111
|
+
msgstr[1] "Plural translation"
|
112
|
+
EOE
|
113
|
+
assert_equal(expected_po, actual_po)
|
114
|
+
end
|
115
|
+
|
116
|
+
def test_msgctxt
|
117
|
+
msg_id = "Context\004Translation"
|
118
|
+
@po_data[msg_id] = "Translated"
|
119
|
+
@po_data.set_comment(msg_id, "#no comment")
|
84
120
|
|
85
|
-
|
86
|
-
|
121
|
+
entry = @po_data.generate_po_entry(msg_id)
|
122
|
+
assert_equal(<<-'EOE', entry)
|
87
123
|
#no comment
|
88
124
|
msgctxt "Context"
|
89
125
|
msgid "Translation"
|
90
126
|
msgstr "Translated"
|
91
127
|
EOE
|
128
|
+
end
|
92
129
|
end
|
93
130
|
end
|
94
131
|
|
@@ -177,6 +214,7 @@ EOH
|
|
177
214
|
def po_content
|
178
215
|
<<-EOP
|
179
216
|
#{po_header(@po_formatted_time, @po_formatted_time)}
|
217
|
+
|
180
218
|
#: hello.rb:1
|
181
219
|
msgid "World"
|
182
220
|
msgstr "Translated World"
|