module I18n

Public Class Methods

l(object, options={})
Alias for: localize
localize(object, options={}) click to toggle source
# File lib/parsi-localize.rb, line 7
def localize object, options={}
  return '' if object.nil?

  locale = options.delete(:locale) || config.locale
  format = options.delete(:format) || :default

  if format.is_a? Symbol
    format = I18n.t("date.formats.#{format}") if object.is_a? Date
    format = I18n.t("time.formats.#{format}") if object.is_a? Time
  end

  if locale == :fa
    if object.respond_to?(:to_jalali)
      object.to_jalali.strftime(format).with_parsi_digits
    elsif object.respond_to?(:with_parsi_digits)
      object.with_parsi_digits
    else
      config.backend.localize locale, object, format, options
    end
  else
    config.backend.localize locale, object, format, options
  end
end
Also aliased as: l