Sha256: 0f1ccae1b2af259c7e06612376aa9d0ea2cb1e812c9bdc9a45307a0b309bb499

Contents?: true

Size: 900 Bytes

Versions: 1

Compression:

Stored size: 900 Bytes

Contents

require 'parsi-digits'
require 'parsi-date'
require 'i18n'

module I18n
  class << self
    def localize object, options={}
      return '' if object.nil?

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

      if [:default, :short, :long].include? format
        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
    alias :l :localize
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
parsi-localize-0.3.1 lib/parsi-localize.rb