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-1.1.9 lib/translations_ennder/conversions_with_i18n_to_s.rb
translations_ennder-1.1.8 lib/translations_ennder/conversions_with_i18n_to_s.rb
translations_ennder-1.1.7 lib/translations_ennder/conversions_with_i18n_to_s.rb
translations_ennder-1.1.6 lib/translations_ennder/conversions_with_i18n_to_s.rb
translations_ennder-1.1.5 lib/translations_ennder/conversions_with_i18n_to_s.rb
translations_ennder-1.1.4 lib/translations_ennder/conversions_with_i18n_to_s.rb
translations_ennder-1.1.3 lib/translations_ennder/conversions_with_i18n_to_s.rb
translations_ennder-1.1.2 lib/translations_ennder/conversions_with_i18n_to_s.rb
translations_ennder-1.1.1 lib/translations_ennder/conversions_with_i18n_to_s.rb
translations_ennder-1.1.0 lib/translations_ennder/conversions_with_i18n_to_s.rb
translations_ennder-1.0.9 lib/translations_ennder/conversions_with_i18n_to_s.rb
translations_ennder-1.0.8 lib/translations_ennder/conversions_with_i18n_to_s.rb
translations_ennder-1.0.6 lib/translations_ennder/conversions_with_i18n_to_s.rb
translations_ennder-1.0.5 lib/translations_ennder/conversions_with_i18n_to_s.rb
translations_ennder-1.0.4 lib/translations_ennder/conversions_with_i18n_to_s.rb
translations_ennder-1.0.3 lib/translations_ennder/conversions_with_i18n_to_s.rb
translations_ennder-1.0.2 lib/translations_ennder/conversions_with_i18n_to_s.rb
translations_ennder-1.0.1 lib/translations_ennder/conversions_with_i18n_to_s.rb
translations_ennder-1.0.0 lib/translations_ennder/conversions_with_i18n_to_s.rb
translations_ennder-0.9.6 lib/translations_ennder/conversions_with_i18n_to_s.rb