6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/russian/rails_admin_datetime.rb', line 6
def delocalize(date_string, format)
ret = date_string
if I18n.locale == :ru
format.to_s.scan(/%[AaBbp]/) do |match|
case match
when '%B'
english = I18n.t('date.month_names', :locale => :en)[1..-1]
common_month_names = I18n.t('date.common_month_names')[1..-1]
common_month_names.each_with_index {|m, i| ret = ret.gsub(/#{m}/i, english[i]) } unless ret.blank?
when '%b'
english = I18n.t('date.abbr_month_names', :locale => :en)[1..-1]
common_abbr_month_names = I18n.t('date.common_abbr_month_names')[1..-1]
common_abbr_month_names.each_with_index {|m, i| ret = ret.gsub(/#{m}/i, english[i]) } unless ret.blank?
end
end
end
ret = delocalize_without_russian(ret, format)
ret
end
|