Class: Money::LocaleBackend::I18n
- Defined in:
- lib/money/locale_backend/i18n.rb,
sig/lib/money/locale_backend/i18n.rbs
Constant Summary collapse
- KEY_MAP =
{ thousands_separator: :delimiter, decimal_mark: :separator, symbol: :unit, format: :format, }.freeze
Instance Method Summary collapse
-
#initialize ⇒ I18n
constructor
A new instance of I18n.
- #lookup(key, _) ⇒ Object
Constructor Details
#initialize ⇒ I18n
Returns a new instance of I18n.
15 16 17 18 19 |
# File 'lib/money/locale_backend/i18n.rb', line 15 def initialize raise NotSupported, "I18n not found" unless defined?(::I18n) super end |
Instance Method Details
#lookup(key, _) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/money/locale_backend/i18n.rb', line 21 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 |