gettext 1.6.0-mswin32 → 1.7.0-mswin32
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/ChangeLog +65 -0
- data/NEWS +20 -0
- data/README +9 -9
- data/Rakefile +4 -4
- data/data/locale/cs/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/cs/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/de/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/de/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/el/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/el/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/es/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/es/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/fr/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/fr/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/it/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/it/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/ja/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/ja/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/ko/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/ko/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/nl/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/nl/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/pt_BR/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/pt_BR/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/ru/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/ru/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/sv/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/zh/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/zh/LC_MESSAGES/rgettext.mo +0 -0
- data/ext/gettext/Makefile +178 -0
- data/ext/gettext/locale_system-i386-mswin32.def +2 -0
- data/ext/gettext/locale_system-i386-mswin32.exp +0 -0
- data/ext/gettext/locale_system-i386-mswin32.lib +0 -0
- data/ext/gettext/locale_system-i386-mswin32.pdb +0 -0
- data/ext/gettext/locale_system.obj +0 -0
- data/ext/gettext/locale_system.so +0 -0
- data/ext/gettext/mkmf.log +16 -0
- data/ext/gettext/vc70.pdb +0 -0
- data/lib/gettext.rb +38 -12
- data/lib/gettext/container.rb +2 -2
- data/lib/gettext/iconv.rb +2 -2
- data/lib/gettext/locale_cgi.rb +3 -2
- data/lib/gettext/locale_object.rb +8 -8
- data/lib/gettext/locale_posix.rb +2 -2
- data/lib/gettext/locale_table_win32.rb +3 -3
- data/lib/gettext/locale_win32.rb +2 -2
- data/lib/gettext/mo.rb +5 -2
- data/lib/gettext/parser/activerecord.rb +27 -17
- data/lib/gettext/parser/glade.rb +7 -11
- data/lib/gettext/parser/ruby.rb +2 -3
- data/lib/gettext/poparser.rb +298 -298
- data/lib/gettext/rails.rb +220 -85
- data/lib/gettext/rgettext.rb +2 -2
- data/lib/gettext/rmsgfmt.rb +3 -3
- data/lib/gettext/rmsgmerge.rb +2 -2
- data/lib/gettext/string.rb +2 -1
- data/lib/gettext/textdomain.rb +5 -2
- data/lib/gettext/textdomainmanager.rb +3 -3
- data/lib/gettext/version.rb +1 -1
- data/lib/locale_system.so +0 -0
- data/po/cs/rails.po +63 -22
- data/po/cs/rgettext.po +71 -37
- data/po/de/rails.po +54 -16
- data/po/de/rgettext.po +56 -22
- data/po/el/rails.po +54 -16
- data/po/el/rgettext.po +56 -22
- data/po/es/rails.po +57 -20
- data/po/es/rgettext.po +70 -30
- data/po/fr/rails.po +57 -19
- data/po/fr/rgettext.po +61 -25
- data/po/it/rails.po +54 -16
- data/po/it/rgettext.po +56 -22
- data/po/ja/rails.po +55 -18
- data/po/ja/rgettext.po +58 -24
- data/po/ko/rails.po +68 -33
- data/po/ko/rgettext.po +77 -37
- data/po/nl/rails.po +61 -22
- data/po/nl/rgettext.po +72 -36
- data/po/pt_BR/rails.po +54 -16
- data/po/pt_BR/rgettext.po +56 -22
- data/po/rails.pot +54 -16
- data/po/rgettext.pot +55 -21
- data/po/ru/rails.po +68 -26
- data/po/ru/rgettext.po +70 -30
- data/po/sv/rgettext.po +55 -21
- data/po/zh/rails.po +51 -16
- data/po/zh/rgettext.po +59 -23
- data/samples/rails/app/controllers/application.rb +7 -1
- data/samples/rails/app/models/article.rb +0 -6
- data/samples/rails/locale/cs/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/de/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/el/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/es/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/fr/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/ja/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/ko/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/nl/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/pt_BR/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/ru/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/src/poparser.ry +1 -1
- data/test/gettext_test.rb +1 -1
- data/test/gettext_test_parser.rb +0 -1
- data/test/test_rubyparser.rb +0 -11
- metadata +21 -7
data/lib/gettext/rails.rb
CHANGED
@@ -6,15 +6,14 @@
|
|
6
6
|
You may redistribute it and/or modify it under the same
|
7
7
|
license terms as Ruby.
|
8
8
|
|
9
|
-
$Id: rails.rb,v 1.
|
9
|
+
$Id: rails.rb,v 1.43 2006/07/16 15:19:17 mutoh Exp $
|
10
10
|
=end
|
11
11
|
|
12
12
|
require 'gettext/cgi'
|
13
13
|
require 'active_record'
|
14
14
|
require 'active_support'
|
15
15
|
|
16
|
-
module GetText
|
17
|
-
# = GetText for Ruby on Rails
|
16
|
+
module GetText
|
18
17
|
# GetText::Rails supports Ruby on Rails.
|
19
18
|
# You add only 2 lines in your controller, all of the controller/view/models are
|
20
19
|
# targeted the textdomain.
|
@@ -32,6 +31,9 @@ module GetText #:nodoc:
|
|
32
31
|
end
|
33
32
|
|
34
33
|
module_function
|
34
|
+
# call-seq:
|
35
|
+
# bindtextdomain(domainname, options = {})
|
36
|
+
#
|
35
37
|
# Bind a textdomain(#{path}/#{locale}/LC_MESSAGES/#{domainname}.mo) to your program.
|
36
38
|
# Notes the textdomain scope becomes all of the controllers/views/models in your app.
|
37
39
|
# This is different from normal GetText.bindtextomain.
|
@@ -43,16 +45,16 @@ module GetText #:nodoc:
|
|
43
45
|
#
|
44
46
|
# * domainname: the textdomain name.
|
45
47
|
# * options: options as a Hash.
|
46
|
-
#
|
47
|
-
#
|
48
|
-
#
|
49
|
-
#
|
50
|
-
#
|
51
|
-
#
|
52
|
-
#
|
53
|
-
#
|
54
|
-
#
|
55
|
-
#
|
48
|
+
# * :locale - the locale value such as "ja-JP". When the value is nil,
|
49
|
+
# locale is searched the order by this value > "lang" value of QUERY_STRING >
|
50
|
+
# params["lang"] > "lang" value of Cookie > HTTP_ACCEPT_LANGUAGE value
|
51
|
+
# > Default locale(en).
|
52
|
+
# * :path - the path to the mo-files. Default is "RAIL_ROOT/locale".
|
53
|
+
# * :charset - the charset. Generally UTF-8 is recommanded.
|
54
|
+
# And the charset is set order by "the argument of bindtextdomain"
|
55
|
+
# > HTTP_ACCEPT_CHARSET > Default charset(UTF-8).
|
56
|
+
# * :with_model - false if you want to ignore ActiveRecord support.
|
57
|
+
# * :with_helper - false if you want to ignore ApplicationHelper support.
|
56
58
|
#
|
57
59
|
# Note: Don't use locale, charset, with_model argument(not in options).
|
58
60
|
# They are remained for backward compatibility.
|
@@ -126,8 +128,8 @@ module ActionController #:nodoc:
|
|
126
128
|
# Bind a 'textdomain' to all of the controllers/views/models. Call this instead of GetText.bindtextdomain.
|
127
129
|
# * textdomain: the textdomain
|
128
130
|
# * options: options as a Hash.
|
129
|
-
#
|
130
|
-
#
|
131
|
+
# * :charset - the output charset. Default is "UTF-8"
|
132
|
+
# * :content_type - the content type. Default is "text/html"
|
131
133
|
#
|
132
134
|
# locale is searched the order by @params["lang"] > "lang" value of QUERY_STRING >
|
133
135
|
# "lang" value of Cookie > HTTP_ACCEPT_LANGUAGE value > Default locale(en).
|
@@ -156,6 +158,12 @@ module ActionController #:nodoc:
|
|
156
158
|
@@gettext_domainname = domainname
|
157
159
|
@@gettext_content_type = opt[:content_type]
|
158
160
|
end
|
161
|
+
|
162
|
+
# Gets the textdomain name of this controller.
|
163
|
+
def self.textdomainname
|
164
|
+
@@gettext_domainname
|
165
|
+
end
|
166
|
+
|
159
167
|
end
|
160
168
|
|
161
169
|
class TestRequest < AbstractRequest #:nodoc:
|
@@ -168,6 +176,11 @@ module ActionController #:nodoc:
|
|
168
176
|
end
|
169
177
|
|
170
178
|
module ActiveRecord #:nodoc:
|
179
|
+
class Migration
|
180
|
+
extend GetText
|
181
|
+
include GetText
|
182
|
+
end
|
183
|
+
|
171
184
|
module ConnectionAdapters #:nodoc:
|
172
185
|
# An abstract definition of a column in a table.
|
173
186
|
class Column
|
@@ -178,46 +191,79 @@ module ActiveRecord #:nodoc:
|
|
178
191
|
end
|
179
192
|
end
|
180
193
|
end
|
194
|
+
|
195
|
+
module Validations # :nodoc:
|
196
|
+
def self.append_features(base) # :nodoc:
|
197
|
+
super
|
198
|
+
base.extend ClassMethods
|
199
|
+
base.class_eval{
|
200
|
+
def gettext(str) #:nodoc:
|
201
|
+
_(str)
|
202
|
+
end
|
203
|
+
def self.human_attribute_name(attribute_key_name) #:nodoc:
|
204
|
+
s_("#{self}|#{attribute_key_name.humanize}")
|
205
|
+
end
|
206
|
+
|
207
|
+
def self.human_attribute_table_name_for_error(table_name) #:nodoc:
|
208
|
+
_(table_name.gsub(/_/, " "))
|
209
|
+
end
|
210
|
+
}
|
211
|
+
end
|
212
|
+
|
213
|
+
module ClassMethods #:nodoc:
|
214
|
+
@@custom_error_messages_d = {}
|
215
|
+
|
216
|
+
# Very ugly but...
|
217
|
+
def validates_length_of(*attrs) #:nodoc:
|
218
|
+
if attrs.last.is_a?(Hash)
|
219
|
+
msg = attrs.last[:message]
|
220
|
+
if msg
|
221
|
+
@@custom_error_messages_d[msg] = /#{Regexp.escape(msg).sub(/%d/, '(\d+)')}/
|
222
|
+
end
|
223
|
+
end
|
224
|
+
validates_size_of(*attrs)
|
225
|
+
end
|
226
|
+
|
227
|
+
def custom_error_messages_d #:nodoc:
|
228
|
+
@@custom_error_messages_d
|
229
|
+
end
|
230
|
+
end
|
231
|
+
def custom_error_messages_d #:nodoc:
|
232
|
+
self.class.custom_error_messages_d
|
233
|
+
end
|
234
|
+
end
|
181
235
|
|
182
236
|
class Base
|
183
|
-
|
184
|
-
|
237
|
+
include GetText::Rails
|
238
|
+
include Validations
|
239
|
+
|
240
|
+
@@gettext_untranslate = false
|
241
|
+
@@gettext_untranslate_columns = []
|
242
|
+
|
243
|
+
# Untranslate all of the tablename/fieldnames in this model class.
|
244
|
+
def self.untranslate_all
|
245
|
+
@@gettext_untranslate = true
|
185
246
|
end
|
186
247
|
|
187
|
-
|
188
|
-
|
248
|
+
# Returns true if "untranslate_all" is called. Otherwise false.
|
249
|
+
def self.untranslate_all?
|
250
|
+
@@gettext_untranslate
|
189
251
|
end
|
190
252
|
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
# set_error_message_title(msg)
|
196
|
-
#
|
197
|
-
# Sets a your own title of error message dialog.
|
198
|
-
# * msg: [single_msg, plural_msg]. Usually you need to call this with Nn_().
|
199
|
-
# * Returns: [single_msg, plural_msg]
|
200
|
-
def self.set_error_message_title(msg, plural_msg = nil)
|
201
|
-
if msg.kind_of? Array
|
202
|
-
single_msg = msg[0]
|
203
|
-
plural_msg = msg[1]
|
204
|
-
else
|
205
|
-
single_msg = msg
|
206
|
-
end
|
207
|
-
@@error_message_title = [single_msg, plural_msg]
|
253
|
+
# Sets the untranslate columns.
|
254
|
+
# (e.g.) untranslate :foo, :bar, :baz
|
255
|
+
def self.untranslate(*w)
|
256
|
+
@@gettext_untranslate_columns += w.collect{|v| v.to_s}
|
208
257
|
end
|
209
258
|
|
210
|
-
#
|
211
|
-
|
212
|
-
def self.
|
213
|
-
|
214
|
-
msg = attrs.last[:message]
|
215
|
-
@@custom_error_messages_d[msg] = /#{Regexp.escape(msg).sub(/%d/, '(\d+)')}/ if msg
|
216
|
-
end
|
217
|
-
validates_size_of(*attrs)
|
259
|
+
# Returns true if the column is set "untranslate".
|
260
|
+
# (e.g.) untranslate? :foo
|
261
|
+
def self.untranslate?(columnname)
|
262
|
+
@@gettext_untranslate_columns.include?(columnname)
|
218
263
|
end
|
219
|
-
|
220
|
-
|
264
|
+
|
265
|
+
def self.untranslate_data #:nodoc:
|
266
|
+
[@@gettext_untranslate, @@gettext_untranslate_columns]
|
221
267
|
end
|
222
268
|
|
223
269
|
def self.columns
|
@@ -230,46 +276,40 @@ module ActiveRecord #:nodoc:
|
|
230
276
|
end
|
231
277
|
@columns
|
232
278
|
end
|
279
|
+
|
280
|
+
# call-seq:
|
281
|
+
# set_error_message_title(msg)
|
282
|
+
#
|
283
|
+
# ((*Deprecated*))
|
284
|
+
# Use ActionView::Helpers::ActiveRecordHelper::L10n.set_error_message_title
|
285
|
+
# instead.
|
286
|
+
#
|
287
|
+
# Sets a your own title of error message dialog.
|
288
|
+
# * msg: [single_msg, plural_msg]. Usually you need to call this with Nn_().
|
289
|
+
# * Returns: [single_msg, plural_msg]
|
290
|
+
def self.set_error_message_title(msg, plural_msg = nil)
|
291
|
+
ActionView::Helpers::ActiveRecordHelper::L10n.set_error_message_title(msg, plural_msg)
|
292
|
+
end
|
233
293
|
|
234
294
|
# call-seq:
|
235
295
|
# set_error_message_explanation(msg)
|
236
296
|
#
|
297
|
+
# ((*Deprecated*))
|
298
|
+
# Use ActionView::Helpers::ActiveRecordHelper::L10n.set_error_message_explanation
|
299
|
+
# instead.
|
300
|
+
#
|
237
301
|
# Sets a your own explanation of the error message dialog.
|
238
302
|
# * msg: [single_msg, plural_msg]. Usually you need to call this with Nn_().
|
239
303
|
# * Returns: [single_msg, plural_msg]
|
240
304
|
def self.set_error_message_explanation(msg, plural_msg = nil)
|
241
|
-
|
242
|
-
single_msg = msg[0]
|
243
|
-
plural_msg = msg[1]
|
244
|
-
else
|
245
|
-
single_msg = msg
|
246
|
-
end
|
247
|
-
@@error_message_explanation = [single_msg, plural_msg]
|
248
|
-
end
|
249
|
-
|
250
|
-
def error_message_title #:nodoc:
|
251
|
-
if @@error_message_title
|
252
|
-
[_(@@error_message_title[0]), _(@@error_message_title[1])]
|
253
|
-
else
|
254
|
-
nil
|
255
|
-
end
|
256
|
-
end
|
257
|
-
def error_message_explanation #:nodoc:
|
258
|
-
if @@error_message_explanation
|
259
|
-
[_(@@error_message_explanation[0]), _(@@error_message_explanation[1])]
|
260
|
-
else
|
261
|
-
nil
|
262
|
-
end
|
263
|
-
end
|
264
|
-
|
265
|
-
def gettext(str) #:nodoc:
|
266
|
-
_(str)
|
305
|
+
ActionView::Helpers::ActiveRecordHelper::L10n.set_error_message_explanation(msg, plural_msg)
|
267
306
|
end
|
268
307
|
end
|
269
308
|
|
309
|
+
# activerecord-1.14.3/lib/active_record/validations.rb
|
270
310
|
class Errors #:nodoc:
|
271
311
|
include GetText
|
272
|
-
|
312
|
+
|
273
313
|
RE_FIELD_NAME = /%\{fn\}/ #:nodoc:
|
274
314
|
|
275
315
|
# You need to define this here, because this values will be updated by application.
|
@@ -294,8 +334,8 @@ module ActiveRecord #:nodoc:
|
|
294
334
|
}
|
295
335
|
cattr_accessor :default_error_messages_d
|
296
336
|
|
297
|
-
def
|
298
|
-
|
337
|
+
def localize_error_messages # :nodoc:
|
338
|
+
errors = {}
|
299
339
|
@errors.each_key do |attr|
|
300
340
|
@errors[attr].each do |msg|
|
301
341
|
next if msg.nil?
|
@@ -305,8 +345,8 @@ module ActiveRecord #:nodoc:
|
|
305
345
|
if regexp =~ msg
|
306
346
|
custom_msg = @base.gettext(key)
|
307
347
|
custom_msg = _(msg) if custom_msg == msg
|
308
|
-
|
309
|
-
|
348
|
+
custom_msg = _(custom_msg) % $1.to_i
|
349
|
+
break
|
310
350
|
end
|
311
351
|
end
|
312
352
|
unless custom_msg
|
@@ -314,14 +354,36 @@ module ActiveRecord #:nodoc:
|
|
314
354
|
custom_msg = _(msg) if custom_msg == msg
|
315
355
|
end
|
316
356
|
if attr == "base"
|
317
|
-
|
357
|
+
full_message = custom_msg
|
318
358
|
elsif RE_FIELD_NAME =~ custom_msg
|
319
|
-
|
359
|
+
full_message = custom_msg % {:fn => @base.class.human_attribute_name(attr)}
|
320
360
|
else
|
321
|
-
|
361
|
+
full_message = @base.class.human_attribute_name(attr) + " " + custom_msg
|
322
362
|
end
|
363
|
+
errors[attr] = full_message
|
323
364
|
end
|
324
365
|
end
|
366
|
+
errors
|
367
|
+
end
|
368
|
+
|
369
|
+
def on(attribute) #:nodoc:
|
370
|
+
errors = localize_error_messages
|
371
|
+
if errors[attribute.to_s].nil?
|
372
|
+
nil
|
373
|
+
elsif errors[attribute.to_s].length == 1
|
374
|
+
errors[attribute.to_s].first
|
375
|
+
else
|
376
|
+
errors[attribute.to_s]
|
377
|
+
end
|
378
|
+
end
|
379
|
+
|
380
|
+
def full_messages #:nodoc:
|
381
|
+
full_messages = []
|
382
|
+
errors = localize_error_messages
|
383
|
+
errors.each do |attr, msg|
|
384
|
+
next if msg.nil?
|
385
|
+
full_messages << msg
|
386
|
+
end
|
325
387
|
full_messages
|
326
388
|
end
|
327
389
|
end
|
@@ -349,7 +411,8 @@ module ActionView #:nodoc:
|
|
349
411
|
module L10n
|
350
412
|
# Separate namespace for textdomain
|
351
413
|
include GetText
|
352
|
-
|
414
|
+
|
415
|
+
bindtextdomain("rails")
|
353
416
|
|
354
417
|
@error_message_title = Nn_("%{num} error prohibited this %{record} from being saved",
|
355
418
|
"%{num} errors prohibited this %{record} from being saved")
|
@@ -357,9 +420,56 @@ module ActionView #:nodoc:
|
|
357
420
|
"There were problems with the following fields:")
|
358
421
|
|
359
422
|
module_function
|
423
|
+
# call-seq:
|
424
|
+
# set_error_message_title(msgs)
|
425
|
+
#
|
426
|
+
# Sets a your own title of error message dialog.
|
427
|
+
# * msgs: [single_msg, plural_msg]. Usually you need to call this with Nn_().
|
428
|
+
# * Returns: [single_msg, plural_msg]
|
429
|
+
def set_error_message_title(msg, plural_msg = nil)
|
430
|
+
if msg.kind_of? Array
|
431
|
+
single_msg = msg[0]
|
432
|
+
plural_msg = msg[1]
|
433
|
+
else
|
434
|
+
single_msg = msg
|
435
|
+
end
|
436
|
+
@error_message_title = [single_msg, plural_msg]
|
437
|
+
end
|
438
|
+
|
439
|
+
# call-seq:
|
440
|
+
# set_error_message_explanation(msg)
|
441
|
+
#
|
442
|
+
# Sets a your own explanation of the error message dialog.
|
443
|
+
# * msg: [single_msg, plural_msg]. Usually you need to call this with Nn_().
|
444
|
+
# * Returns: [single_msg, plural_msg]
|
445
|
+
def set_error_message_explanation(msg, plural_msg = nil)
|
446
|
+
if msg.kind_of? Array
|
447
|
+
single_msg = msg[0]
|
448
|
+
plural_msg = msg[1]
|
449
|
+
else
|
450
|
+
single_msg = msg
|
451
|
+
end
|
452
|
+
@error_message_explanation = [single_msg, plural_msg]
|
453
|
+
end
|
454
|
+
|
455
|
+
def error_message_title #:nodoc:
|
456
|
+
if @error_message_title
|
457
|
+
[_(@error_message_title[0]), _(@error_message_title[1])]
|
458
|
+
else
|
459
|
+
nil
|
460
|
+
end
|
461
|
+
end
|
462
|
+
def error_message_explanation #:nodoc:
|
463
|
+
if @error_message_explanation
|
464
|
+
[_(@error_message_explanation[0]), _(@error_message_explanation[1])]
|
465
|
+
else
|
466
|
+
nil
|
467
|
+
end
|
468
|
+
end
|
469
|
+
|
360
470
|
def render_error_message(object, klass, record, count, options)
|
361
|
-
message_title =
|
362
|
-
message_explanation =
|
471
|
+
message_title = @error_message_title
|
472
|
+
message_explanation = @error_message_explanation
|
363
473
|
|
364
474
|
klass.content_tag("div",
|
365
475
|
klass.content_tag(
|
@@ -373,8 +483,6 @@ module ActionView #:nodoc:
|
|
373
483
|
end
|
374
484
|
|
375
485
|
def error_messages_for(object, object_name, klass, options = {})
|
376
|
-
textdomain("rails")
|
377
|
-
|
378
486
|
options = options.symbolize_keys
|
379
487
|
|
380
488
|
if object && ! object.errors.empty?
|
@@ -389,6 +497,33 @@ module ActionView #:nodoc:
|
|
389
497
|
L10n.error_messages_for(object, object_name, self, options)
|
390
498
|
end
|
391
499
|
end
|
500
|
+
|
501
|
+
module DateHelper #:nodoc: all
|
502
|
+
include GetText
|
503
|
+
alias distance_of_time_in_words_without_locale distance_of_time_in_words #:nodoc:
|
504
|
+
|
505
|
+
bindtextdomain("rails")
|
506
|
+
|
507
|
+
# This is FAKE constant. The messages are found by rgettext as the msgid.
|
508
|
+
MESSAGESS = [N_('less than 5 seconds'), N_('less than 10 seconds'), N_('less than 20 seconds'),
|
509
|
+
N_('half a minute'), N_('less than a minute')]
|
510
|
+
MINUTES = [/^(\d+) minutes?$/, Nn_('1 minute', '%{num} minutes')]
|
511
|
+
HOURS = [/^about (\d+) hours?$/, Nn_('about 1 hour', 'about %{num} hours')]
|
512
|
+
DAYS = [/^(\d+) days?$/, Nn_('1 day', '%{num} days')]
|
513
|
+
|
514
|
+
def distance_of_time_in_words(from_time, to_time = 0, include_seconds = false)
|
515
|
+
msg = distance_of_time_in_words_without_locale(from_time, to_time, include_seconds)
|
516
|
+
match = false
|
517
|
+
[MINUTES, HOURS, DAYS].each do |regexp, nn|
|
518
|
+
if regexp =~ msg
|
519
|
+
match = true
|
520
|
+
msg = n_(nn, $1.to_i) % {:num => $1}
|
521
|
+
break
|
522
|
+
end
|
523
|
+
end
|
524
|
+
match ? msg : _(msg)
|
525
|
+
end
|
526
|
+
end
|
392
527
|
end
|
393
528
|
end
|
394
529
|
|
data/lib/gettext/rgettext.rb
CHANGED
@@ -18,14 +18,14 @@ require 'rbconfig'
|
|
18
18
|
|
19
19
|
module GetText
|
20
20
|
|
21
|
-
module RGetText
|
21
|
+
module RGetText #:nodoc:
|
22
22
|
extend GetText
|
23
23
|
|
24
24
|
bindtextdomain("rgettext")
|
25
25
|
|
26
26
|
# constant values
|
27
27
|
VERSION = GetText::VERSION
|
28
|
-
DATE = %w($Date: 2006/06/
|
28
|
+
DATE = %w($Date: 2006/06/11 15:36:20 $)[1]
|
29
29
|
MAX_LINE_LEN = 70
|
30
30
|
|
31
31
|
@ex_parsers = []
|