fast_gettext 0.6.7 → 0.6.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/Gemfile.lock +14 -15
- data/Rakefile +4 -2
- data/lib/fast_gettext/po_file.rb +7 -1
- data/lib/fast_gettext/vendor/poparser.rb +256 -206
- data/lib/fast_gettext/version.rb +1 -1
- data/spec/fast_gettext/translation_repository/po_spec.rb +17 -5
- data/spec/spec_helper.rb +1 -2
- metadata +4 -4
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,29 +1,27 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fast_gettext (0.6.
|
4
|
+
fast_gettext (0.6.8)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: http://rubygems.org/
|
8
8
|
specs:
|
9
|
-
activemodel (3.
|
10
|
-
activesupport (= 3.
|
11
|
-
bcrypt-ruby (~> 3.0.0)
|
9
|
+
activemodel (3.2.5)
|
10
|
+
activesupport (= 3.2.5)
|
12
11
|
builder (~> 3.0.0)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
arel (~> 2.2.1)
|
12
|
+
activerecord (3.2.5)
|
13
|
+
activemodel (= 3.2.5)
|
14
|
+
activesupport (= 3.2.5)
|
15
|
+
arel (~> 3.0.2)
|
18
16
|
tzinfo (~> 0.3.29)
|
19
|
-
activesupport (3.
|
17
|
+
activesupport (3.2.5)
|
18
|
+
i18n (~> 0.6)
|
20
19
|
multi_json (~> 1.0)
|
21
|
-
arel (
|
22
|
-
bcrypt-ruby (3.0.1)
|
20
|
+
arel (3.0.2)
|
23
21
|
builder (3.0.0)
|
24
22
|
diff-lcs (1.1.3)
|
25
23
|
i18n (0.6.0)
|
26
|
-
multi_json (1.
|
24
|
+
multi_json (1.3.6)
|
27
25
|
rake (0.9.2)
|
28
26
|
rspec (2.6.0)
|
29
27
|
rspec-core (~> 2.6.0)
|
@@ -33,8 +31,8 @@ GEM
|
|
33
31
|
rspec-expectations (2.6.0)
|
34
32
|
diff-lcs (~> 1.1.2)
|
35
33
|
rspec-mocks (2.6.0)
|
36
|
-
sqlite3 (1.3.
|
37
|
-
tzinfo (0.3.
|
34
|
+
sqlite3 (1.3.6)
|
35
|
+
tzinfo (0.3.33)
|
38
36
|
|
39
37
|
PLATFORMS
|
40
38
|
ruby
|
@@ -42,6 +40,7 @@ PLATFORMS
|
|
42
40
|
DEPENDENCIES
|
43
41
|
activerecord
|
44
42
|
fast_gettext!
|
43
|
+
i18n
|
45
44
|
rake
|
46
45
|
rspec (~> 2)
|
47
46
|
sqlite3
|
data/Rakefile
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
2
|
|
3
3
|
task :default do
|
4
|
-
|
5
|
-
|
4
|
+
['~>2', '~>3'].each do |version|
|
5
|
+
sh "export AR='#{version}' && (bundle check || bundle) && bundle exec rspec spec"
|
6
|
+
end
|
7
|
+
sh "git checkout Gemfile.lock"
|
6
8
|
end
|
7
9
|
|
8
10
|
task :benchmark do
|
data/lib/fast_gettext/po_file.rb
CHANGED
@@ -6,8 +6,14 @@ module FastGettext
|
|
6
6
|
class PoFile
|
7
7
|
def self.to_mo_file(file, options={})
|
8
8
|
require 'fast_gettext/vendor/poparser'
|
9
|
+
parser = FastGettext::GetText::PoParser.new
|
10
|
+
|
11
|
+
warn ":ignore_obsolete is no longer supported, use :report_warning" if options.key? :ignore_obsolete
|
12
|
+
parser.ignore_fuzzy = options[:ignore_fuzzy]
|
13
|
+
parser.report_warning = options.fetch(:report_warning, true)
|
14
|
+
|
9
15
|
mo_file = FastGettext::GetText::MOFile.new
|
10
|
-
|
16
|
+
parser.parse(File.read(file), mo_file)
|
11
17
|
MoFile.new(mo_file)
|
12
18
|
end
|
13
19
|
end
|
@@ -1,27 +1,43 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# poparser.rb - Generate a .mo
|
4
|
+
#
|
5
|
+
# Copyright (C) 2003-2009 Masao Mutoh <mutomasa at gmail.com>
|
6
|
+
# Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com>
|
7
|
+
#
|
8
|
+
# You may redistribute it and/or modify it under the same
|
9
|
+
# license terms as Ruby or LGPL.
|
9
10
|
|
10
11
|
#MODIFIED
|
11
|
-
# removed include GetText
|
12
|
-
# added stub translation method _(
|
13
|
-
require 'racc/parser'
|
12
|
+
# removed include GetText
|
13
|
+
# added stub translation method _(message_id)
|
14
14
|
|
15
|
+
require 'racc/parser.rb'
|
15
16
|
module FastGettext
|
16
17
|
module GetText
|
17
|
-
|
18
18
|
class PoParser < Racc::Parser
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
module_eval(<<'...end poparser.ry/module_eval...', 'poparser.ry', 118)
|
21
|
+
|
22
|
+
def _(message_id)
|
23
|
+
message_id
|
24
|
+
end
|
25
|
+
private :_
|
26
|
+
|
27
|
+
attr_writer :ignore_fuzzy, :report_warning
|
28
|
+
def initialize
|
29
|
+
@ignore_fuzzy = true
|
30
|
+
@report_warning = true
|
31
|
+
end
|
32
|
+
|
33
|
+
def ignore_fuzzy?
|
34
|
+
@ignore_fuzzy
|
35
|
+
end
|
36
|
+
|
37
|
+
def report_warning?
|
38
|
+
@report_warning
|
39
|
+
end
|
23
40
|
|
24
|
-
module_eval <<'..end src/poparser.ry modeval..id7a99570e05', 'src/poparser.ry', 108
|
25
41
|
def unescape(orig)
|
26
42
|
ret = orig.gsub(/\\n/, "\n")
|
27
43
|
ret.gsub!(/\\t/, "\t")
|
@@ -29,13 +45,18 @@ module_eval <<'..end src/poparser.ry modeval..id7a99570e05', 'src/poparser.ry',
|
|
29
45
|
ret.gsub!(/\\"/, "\"")
|
30
46
|
ret
|
31
47
|
end
|
32
|
-
|
33
|
-
|
48
|
+
private :unescape
|
49
|
+
|
50
|
+
def unescape_string(string)
|
51
|
+
string.gsub(/\\\\/, "\\")
|
52
|
+
end
|
53
|
+
private :unescape_string
|
54
|
+
|
55
|
+
def parse(str, data)
|
34
56
|
@comments = []
|
35
57
|
@data = data
|
36
58
|
@fuzzy = false
|
37
59
|
@msgctxt = ""
|
38
|
-
$ignore_fuzzy = ignore_fuzzy
|
39
60
|
|
40
61
|
str.strip!
|
41
62
|
@q = []
|
@@ -59,24 +80,24 @@ module_eval <<'..end src/poparser.ry modeval..id7a99570e05', 'src/poparser.ry',
|
|
59
80
|
@q.push [:PLURAL_NUM, $1]
|
60
81
|
str = $'
|
61
82
|
when /\A\#~(.*)/
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
83
|
+
if report_warning?
|
84
|
+
$stderr.print _("Warning: obsolete msgid exists.\n")
|
85
|
+
$stderr.print " #{$&}\n"
|
86
|
+
end
|
66
87
|
@q.push [:COMMENT, $&]
|
67
88
|
str = $'
|
68
89
|
when /\A\#(.*)/
|
69
90
|
@q.push [:COMMENT, $&]
|
70
|
-
str = $'
|
71
|
-
when /\A\"(.*)\"/
|
72
91
|
str = $'
|
92
|
+
when /\A\"(.*)\"/
|
73
93
|
@q.push [:STRING, unescape_string($1)]
|
94
|
+
str = $'
|
74
95
|
else
|
75
96
|
#c = str[0,1]
|
76
97
|
#@q.push [:STRING, c]
|
77
98
|
str = str[1..-1]
|
78
99
|
end
|
79
|
-
end
|
100
|
+
end
|
80
101
|
@q.push [false, '$end']
|
81
102
|
if $DEBUG
|
82
103
|
@q.each do |a,b|
|
@@ -91,7 +112,7 @@ module_eval <<'..end src/poparser.ry modeval..id7a99570e05', 'src/poparser.ry',
|
|
91
112
|
end
|
92
113
|
@data
|
93
114
|
end
|
94
|
-
|
115
|
+
|
95
116
|
def next_token
|
96
117
|
@q.shift
|
97
118
|
end
|
@@ -104,175 +125,199 @@ module_eval <<'..end src/poparser.ry modeval..id7a99570e05', 'src/poparser.ry',
|
|
104
125
|
@comments.clear
|
105
126
|
@msgctxt = ""
|
106
127
|
end
|
107
|
-
|
128
|
+
|
108
129
|
def on_comment(comment)
|
109
130
|
@fuzzy = true if (/fuzzy/ =~ comment)
|
110
131
|
@comments << comment
|
111
|
-
end
|
132
|
+
end
|
112
133
|
|
113
|
-
def
|
114
|
-
|
134
|
+
def parse_file(po_file, data)
|
135
|
+
args = [ po_file ]
|
136
|
+
# In Ruby 1.9, we must detect proper encoding of a PO file.
|
137
|
+
if String.instance_methods.include?(:encode)
|
138
|
+
encoding = detect_file_encoding(po_file)
|
139
|
+
args << "r:#{encoding}"
|
140
|
+
end
|
141
|
+
@po_file = po_file
|
142
|
+
parse(File.open(*args) {|io| io.read }, data)
|
115
143
|
end
|
116
144
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
nil, nil,
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
145
|
+
def detect_file_encoding(po_file)
|
146
|
+
open(po_file, :encoding => 'ASCII-8BIT') do |input|
|
147
|
+
input.lines.each do |line|
|
148
|
+
return Encoding.find($1) if %r["Content-Type:.*\scharset=(.*)\\n"] =~ line
|
149
|
+
end
|
150
|
+
end
|
151
|
+
Encoding.default_external
|
152
|
+
end
|
153
|
+
private :detect_file_encoding
|
154
|
+
...end poparser.ry/module_eval...
|
155
|
+
##### State transition tables begin ###
|
156
|
+
|
157
|
+
racc_action_table = [
|
158
|
+
2, 13, 10, 9, 6, 17, 16, 15, 22, 15,
|
159
|
+
15, 13, 13, 13, 15, 11, 22, 24, 13, 15 ]
|
160
|
+
|
161
|
+
racc_action_check = [
|
162
|
+
1, 17, 1, 1, 1, 14, 14, 14, 19, 19,
|
163
|
+
12, 6, 16, 9, 18, 2, 20, 22, 24, 25 ]
|
164
|
+
|
165
|
+
racc_action_pointer = [
|
166
|
+
nil, 0, 15, nil, nil, nil, 4, nil, nil, 6,
|
167
|
+
nil, nil, 3, nil, 0, nil, 5, -6, 7, 2,
|
168
|
+
10, nil, 9, nil, 11, 12 ]
|
169
|
+
|
170
|
+
racc_action_default = [
|
171
|
+
-1, -16, -16, -2, -3, -4, -16, -6, -7, -16,
|
172
|
+
-13, 26, -5, -15, -16, -14, -16, -16, -8, -16,
|
173
|
+
-9, -11, -16, -10, -16, -12 ]
|
174
|
+
|
175
|
+
racc_goto_table = [
|
176
|
+
12, 21, 23, 14, 4, 5, 3, 7, 8, 20,
|
177
|
+
18, 19, 1, nil, nil, nil, nil, nil, 25 ]
|
178
|
+
|
179
|
+
racc_goto_check = [
|
180
|
+
5, 9, 9, 5, 3, 4, 2, 6, 7, 8,
|
181
|
+
5, 5, 1, nil, nil, nil, nil, nil, 5 ]
|
182
|
+
|
183
|
+
racc_goto_pointer = [
|
184
|
+
nil, 12, 5, 3, 4, -6, 6, 7, -10, -18 ]
|
185
|
+
|
186
|
+
racc_goto_default = [
|
187
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil ]
|
188
|
+
|
189
|
+
racc_reduce_table = [
|
190
|
+
0, 0, :racc_error,
|
191
|
+
0, 10, :_reduce_none,
|
192
|
+
2, 10, :_reduce_none,
|
193
|
+
2, 10, :_reduce_none,
|
194
|
+
2, 10, :_reduce_none,
|
195
|
+
2, 12, :_reduce_5,
|
196
|
+
1, 13, :_reduce_none,
|
197
|
+
1, 13, :_reduce_none,
|
198
|
+
4, 15, :_reduce_8,
|
199
|
+
5, 16, :_reduce_9,
|
200
|
+
2, 17, :_reduce_10,
|
201
|
+
1, 17, :_reduce_none,
|
202
|
+
3, 18, :_reduce_12,
|
203
|
+
1, 11, :_reduce_13,
|
204
|
+
2, 14, :_reduce_14,
|
205
|
+
1, 14, :_reduce_15 ]
|
206
|
+
|
207
|
+
racc_reduce_n = 16
|
208
|
+
|
209
|
+
racc_shift_n = 26
|
210
|
+
|
211
|
+
racc_token_table = {
|
212
|
+
false => 0,
|
213
|
+
:error => 1,
|
214
|
+
:COMMENT => 2,
|
215
|
+
:MSGID => 3,
|
216
|
+
:MSGCTXT => 4,
|
217
|
+
:MSGID_PLURAL => 5,
|
218
|
+
:MSGSTR => 6,
|
219
|
+
:STRING => 7,
|
220
|
+
:PLURAL_NUM => 8 }
|
221
|
+
|
222
|
+
racc_nt_base = 9
|
223
|
+
|
224
|
+
racc_use_result_var = true
|
225
|
+
|
226
|
+
Racc_arg = [
|
227
|
+
racc_action_table,
|
228
|
+
racc_action_check,
|
229
|
+
racc_action_default,
|
230
|
+
racc_action_pointer,
|
231
|
+
racc_goto_table,
|
232
|
+
racc_goto_check,
|
233
|
+
racc_goto_default,
|
234
|
+
racc_goto_pointer,
|
235
|
+
racc_nt_base,
|
236
|
+
racc_reduce_table,
|
237
|
+
racc_token_table,
|
238
|
+
racc_shift_n,
|
239
|
+
racc_reduce_n,
|
240
|
+
racc_use_result_var ]
|
241
|
+
|
242
|
+
Racc_token_to_s_table = [
|
243
|
+
"$end",
|
244
|
+
"error",
|
245
|
+
"COMMENT",
|
246
|
+
"MSGID",
|
247
|
+
"MSGCTXT",
|
248
|
+
"MSGID_PLURAL",
|
249
|
+
"MSGSTR",
|
250
|
+
"STRING",
|
251
|
+
"PLURAL_NUM",
|
252
|
+
"$start",
|
253
|
+
"msgfmt",
|
254
|
+
"comment",
|
255
|
+
"msgctxt",
|
256
|
+
"message",
|
257
|
+
"string_list",
|
258
|
+
"single_message",
|
259
|
+
"plural_message",
|
260
|
+
"msgstr_plural",
|
261
|
+
"msgstr_plural_line" ]
|
262
|
+
|
263
|
+
Racc_debug_parser = true
|
264
|
+
|
265
|
+
##### State transition tables end #####
|
266
|
+
|
267
|
+
# reduce 0 omitted
|
268
|
+
|
269
|
+
# reduce 1 omitted
|
270
|
+
|
271
|
+
# reduce 2 omitted
|
272
|
+
|
273
|
+
# reduce 3 omitted
|
274
|
+
|
275
|
+
# reduce 4 omitted
|
276
|
+
|
277
|
+
module_eval(<<'.,.,', 'poparser.ry', 25)
|
278
|
+
def _reduce_5(val, _values, result)
|
279
|
+
@msgctxt = unescape(val[1]) + "\004"
|
280
|
+
|
281
|
+
result
|
245
282
|
end
|
246
283
|
.,.,
|
247
284
|
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
module_eval
|
253
|
-
def _reduce_8(
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
285
|
+
# reduce 6 omitted
|
286
|
+
|
287
|
+
# reduce 7 omitted
|
288
|
+
|
289
|
+
module_eval(<<'.,.,', 'poparser.ry', 37)
|
290
|
+
def _reduce_8(val, _values, result)
|
291
|
+
msgid_raw = val[1]
|
292
|
+
msgid = unescape(msgid_raw)
|
293
|
+
msgstr = unescape(val[3])
|
294
|
+
use_message_p = true
|
295
|
+
if @fuzzy and not msgid.empty?
|
296
|
+
use_message_p = (not ignore_fuzzy?)
|
297
|
+
if report_warning?
|
298
|
+
if ignore_fuzzy?
|
299
|
+
$stderr.print _("Warning: fuzzy message was ignored.\n")
|
300
|
+
else
|
301
|
+
$stderr.print _("Warning: fuzzy message was used.\n")
|
302
|
+
end
|
303
|
+
$stderr.print " #{@po_file}: msgid '#{msgid_raw}'\n"
|
260
304
|
end
|
261
|
-
@fuzzy = false
|
262
|
-
else
|
263
|
-
on_message(@msgctxt + unescape(val[1]), unescape(val[3]))
|
264
305
|
end
|
306
|
+
@fuzzy = false
|
307
|
+
on_message(@msgctxt + msgid, msgstr) if use_message_p
|
265
308
|
result = ""
|
266
|
-
|
309
|
+
result
|
267
310
|
end
|
268
311
|
.,.,
|
269
312
|
|
270
|
-
module_eval
|
271
|
-
def _reduce_9(
|
272
|
-
|
313
|
+
module_eval(<<'.,.,', 'poparser.ry', 60)
|
314
|
+
def _reduce_9(val, _values, result)
|
315
|
+
if @fuzzy and ignore_fuzzy?
|
273
316
|
if val[1] != ""
|
274
|
-
|
275
|
-
|
317
|
+
if report_warning?
|
318
|
+
$stderr.print _("Warning: fuzzy message was ignored.\n")
|
319
|
+
$stderr.print "msgid = '#{val[1]}\n"
|
320
|
+
end
|
276
321
|
else
|
277
322
|
on_message('', unescape(val[3]))
|
278
323
|
end
|
@@ -281,56 +326,61 @@ module_eval <<'.,.,', 'src/poparser.ry', 65
|
|
281
326
|
on_message(@msgctxt + unescape(val[1]) + "\000" + unescape(val[3]), unescape(val[4]))
|
282
327
|
end
|
283
328
|
result = ""
|
284
|
-
|
329
|
+
|
330
|
+
result
|
285
331
|
end
|
286
332
|
.,.,
|
287
333
|
|
288
|
-
module_eval
|
289
|
-
def _reduce_10(
|
290
|
-
|
334
|
+
module_eval(<<'.,.,', 'poparser.ry', 80)
|
335
|
+
def _reduce_10(val, _values, result)
|
336
|
+
if val[0].size > 0
|
291
337
|
result = val[0] + "\000" + val[1]
|
292
338
|
else
|
293
339
|
result = ""
|
294
340
|
end
|
295
|
-
|
341
|
+
|
342
|
+
result
|
296
343
|
end
|
297
344
|
.,.,
|
298
345
|
|
299
|
-
|
346
|
+
# reduce 11 omitted
|
347
|
+
|
348
|
+
module_eval(<<'.,.,', 'poparser.ry', 92)
|
349
|
+
def _reduce_12(val, _values, result)
|
350
|
+
result = val[2]
|
300
351
|
|
301
|
-
|
302
|
-
def _reduce_12( val, _values, result )
|
303
|
-
result = val[2]
|
304
|
-
result
|
352
|
+
result
|
305
353
|
end
|
306
354
|
.,.,
|
307
355
|
|
308
|
-
module_eval
|
309
|
-
def _reduce_13(
|
310
|
-
|
311
|
-
|
356
|
+
module_eval(<<'.,.,', 'poparser.ry', 99)
|
357
|
+
def _reduce_13(val, _values, result)
|
358
|
+
on_comment(val[0])
|
359
|
+
|
360
|
+
result
|
312
361
|
end
|
313
362
|
.,.,
|
314
363
|
|
315
|
-
module_eval
|
316
|
-
def _reduce_14(
|
317
|
-
|
318
|
-
|
364
|
+
module_eval(<<'.,.,', 'poparser.ry', 107)
|
365
|
+
def _reduce_14(val, _values, result)
|
366
|
+
result = val.delete_if{|item| item == ""}.join
|
367
|
+
|
368
|
+
result
|
319
369
|
end
|
320
370
|
.,.,
|
321
371
|
|
322
|
-
module_eval
|
323
|
-
def _reduce_15(
|
324
|
-
|
325
|
-
|
372
|
+
module_eval(<<'.,.,', 'poparser.ry', 111)
|
373
|
+
def _reduce_15(val, _values, result)
|
374
|
+
result = val[0]
|
375
|
+
|
376
|
+
result
|
326
377
|
end
|
327
378
|
.,.,
|
328
379
|
|
329
|
-
|
330
|
-
|
331
|
-
|
380
|
+
def _reduce_none(val, _values, result)
|
381
|
+
val[0]
|
382
|
+
end
|
332
383
|
|
333
384
|
end # class PoParser
|
334
|
-
|
335
385
|
end # module GetText
|
336
386
|
end
|
data/lib/fast_gettext/version.rb
CHANGED
@@ -28,14 +28,26 @@ describe 'FastGettext::TranslationRepository::Po' do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
describe 'fuzzy' do
|
31
|
-
|
31
|
+
before do
|
32
|
+
@fuzzy = File.join('spec','fuzzy_locale')
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should use fuzzy by default" do
|
36
|
+
$stderr.should_receive(:print).at_least(:once)
|
37
|
+
repo = FastGettext::TranslationRepository.build('test',:path=>@fuzzy,:type=>:po)
|
38
|
+
repo["%{relative_time} ago"].should == "vor %{relative_time}"
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should warn on fuzzy when ignoring" do
|
32
42
|
$stderr.should_receive(:print).at_least(:once)
|
33
|
-
FastGettext::TranslationRepository.build('test',:path
|
43
|
+
repo = FastGettext::TranslationRepository.build('test',:path=>@fuzzy,:type=>:po, :ignore_fuzzy => true)
|
44
|
+
repo["%{relative_time} ago"].should == nil
|
34
45
|
end
|
35
46
|
|
36
|
-
it "should ignore fuzzy when told to do so" do
|
47
|
+
it "should ignore fuzzy and not report when told to do so" do
|
37
48
|
$stderr.should_not_receive(:print)
|
38
|
-
FastGettext::TranslationRepository.build('test',:path
|
49
|
+
repo = FastGettext::TranslationRepository.build('test',:path=>@fuzzy,:type=>:po, :ignore_fuzzy => true, :report_warning => false)
|
50
|
+
repo["%{relative_time} ago"].should == nil
|
39
51
|
end
|
40
52
|
end
|
41
53
|
|
@@ -47,7 +59,7 @@ describe 'FastGettext::TranslationRepository::Po' do
|
|
47
59
|
|
48
60
|
it "should ignore obsolete when told to do so" do
|
49
61
|
$stderr.should_not_receive(:print)
|
50
|
-
FastGettext::TranslationRepository.build('test',:path=>File.join('spec','obsolete_locale'),:type=>:po, :
|
62
|
+
FastGettext::TranslationRepository.build('test',:path=>File.join('spec','obsolete_locale'),:type=>:po, :report_warning => false)
|
51
63
|
end
|
52
64
|
end
|
53
65
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
# $VERBOSE = true # ignore complaints in spec files
|
2
2
|
|
3
3
|
# ---- requirements
|
4
|
-
require 'rubygems'
|
5
4
|
$LOAD_PATH.unshift File.expand_path("../lib", File.dirname(__FILE__))
|
6
5
|
require 'fast_gettext'
|
7
6
|
|
8
7
|
# ---- revert to defaults
|
9
8
|
RSpec.configure do |config|
|
10
|
-
config.before
|
9
|
+
config.before do
|
11
10
|
FastGettext.locale = 'de'
|
12
11
|
FastGettext.available_locales = nil
|
13
12
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fast_gettext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-06-15 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email: michael@grosser.it
|
@@ -110,7 +110,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
110
110
|
version: '0'
|
111
111
|
segments:
|
112
112
|
- 0
|
113
|
-
hash:
|
113
|
+
hash: -3956951288386353458
|
114
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
115
|
none: false
|
116
116
|
requirements:
|
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
119
|
version: '0'
|
120
120
|
segments:
|
121
121
|
- 0
|
122
|
-
hash:
|
122
|
+
hash: -3956951288386353458
|
123
123
|
requirements: []
|
124
124
|
rubyforge_project:
|
125
125
|
rubygems_version: 1.8.24
|