Sha256: 17c3aa6133a573f08cc1462009ab73e3a975a1540c0735c75b45b183e56ae5ee
Contents?: true
Size: 793 Bytes
Versions: 22
Compression:
Stored size: 793 Bytes
Contents
# Pour que to_s prenne en compte les formats localisés module ConversionsWithI18nToS def self.included(base) base.instance_eval do # to_formatted_s # devient : # to_formatted_s_without_i18n # et : # to_formatted_s_with_i18n # devient : # to_formatted_s # alias_method_chain :to_formatted_s, :i18n alias_method_chain :to_s, :i18n # alias_method :to_s, :to_formatted_s end end # def to_formatted_s_with_i18n(format = :default) def to_s_with_i18n(p_format = :default) begin _format = I18n.t("time.formats.#{p_format}", :raise => true) rescue I18n::MissingTranslationData return to_s_without_i18n(p_format) end # Rails.logger.debug "DEBUG JBA : #{self.class.name} : format.#{p_format}=[#{_format}]" I18n.l( self, :format => _format ) end end
Version data entries
22 entries across 22 versions & 1 rubygems
Version | Path |
---|---|
translations_ennder-0.9.5 | lib/translations_ennder/conversions_with_i18n_to_s.rb |
translations_ennder-0.9.0 | lib/translations_ennder/conversions_with_i18n_to_s.rb |