Sha256: bc4351934e8b13f88b0a4a1f031cc3f0263ef0c381464d8ea04f6a28f3a47978

Contents?: true

Size: 569 Bytes

Versions: 2

Compression:

Stored size: 569 Bytes

Contents

require 'money/locale_backend/base'

class Money
  module LocaleBackend
    class I18n < Base
      KEY_MAP = {
        thousands_separator: :delimiter,
        decimal_mark: :separator
      }.freeze

      def initialize
        raise NotSupported, 'I18n not found' unless defined?(::I18n)
      end

      def lookup(key, _)
        i18n_key = KEY_MAP[key]

        ::I18n.t i18n_key, scope: 'number.currency.format', raise: true
      rescue ::I18n::MissingTranslationData
        ::I18n.t i18n_key, scope: 'number.format', default: nil
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
money-6.13.1 lib/money/locale_backend/i18n.rb
money-6.13.0 lib/money/locale_backend/i18n.rb