Sha256: 9ff0499a5e0bbf877d7bc86c3267e1a3a233d65fd7ddcabc3414ed1fb5a8c29f
Contents?: true
Size: 1.54 KB
Versions: 4
Compression:
Stored size: 1.54 KB
Contents
require 'rails_admin/config/fields/types/datetime' module RailsAdmin module Config module Fields module Types class Datetime < RailsAdmin::Config::Fields::Base def parse_input(params) str = params[name] if I18n.locale == :ru strftime_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| str = str.gsub(/#{m}/i, english[i]) } unless str.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| str = str.gsub(/#{m}/i, english[i]) } unless str.blank? end end end params[name] = parser.parse_string(str) if params[name] end register_instance_option :formatted_value do ret = if time = (value || default_value) opt = {format: strftime_format, standalone: true} Russian.force_standalone = true r = ::I18n.l(time, opt) Russian.force_standalone = false r else ''.html_safe end ret end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems