2018-11-09 22:58:08 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class CustomI18nBackend < I18n::Backend::Simple
|
|
|
|
attr_accessor :date_format
|
|
|
|
|
2021-06-07 16:34:58 +08:00
|
|
|
# Gets I18n configuration object.
|
|
|
|
def date_format
|
|
|
|
Thread.current[:i18n_date_format] ||= Constants::DEFAULT_DATE_FORMAT
|
|
|
|
end
|
|
|
|
|
|
|
|
# Sets I18n configuration object.
|
|
|
|
def date_format=(value)
|
|
|
|
Thread.current[:i18n_date_format] = value
|
|
|
|
end
|
|
|
|
|
2018-11-09 22:58:08 +08:00
|
|
|
def localize(locale, object, format = :default, options = {})
|
2021-06-15 17:15:46 +08:00
|
|
|
options[:date_format] ||= date_format
|
2018-11-09 22:58:08 +08:00
|
|
|
super(locale, object, format, options)
|
|
|
|
end
|
|
|
|
end
|