7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/parsi-localize.rb', line 7
def localize object, options={}
return '' if object.nil?
locale = options.delete(:locale) || config.locale
format = options.delete(:format) || :default
if format.is_a? Symbol
format = I18n.t("date.formats.#{format}") if object.is_a? Date
format = I18n.t("time.formats.#{format}") if object.is_a? Time
end
if locale == :fa
if object.respond_to?(:to_jalali)
object.to_jalali.strftime(format).with_parsi_digits
elsif object.respond_to?(:with_parsi_digits)
object.with_parsi_digits
else
config.backend.localize locale, object, format, options
end
else
config.backend.localize locale, object, format, options
end
end
|