Skip to content

Commit

Permalink
Allow for :symbol lookup in LocaleBackened::I18n (tonsky#843)
Browse files Browse the repository at this point in the history
  • Loading branch information
antstorm authored Jan 7, 2019
1 parent da1559d commit 0ac7cf4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/money/locale_backend/i18n.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ module LocaleBackend
class I18n < Base
KEY_MAP = {
thousands_separator: :delimiter,
decimal_mark: :separator
decimal_mark: :separator,
symbol: :unit
}.freeze

def initialize
Expand Down
10 changes: 9 additions & 1 deletion spec/locale_backend/i18n_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
before do
I18n.locale = :de
I18n.backend.store_translations(:de, number: {
currency: { format: { delimiter: '.', separator: ',' } }
currency: { format: { delimiter: '.', separator: ',', unit: '$' } }
})
end

Expand All @@ -32,6 +32,10 @@
it 'returns decimal_mark based on the current locale' do
expect(subject.lookup(:decimal_mark, nil)).to eq(',')
end

it 'returns symbol based on the current locale' do
expect(subject.lookup(:symbol, nil)).to eq('$')
end
end

context 'with number.format defined' do
Expand All @@ -57,6 +61,10 @@
it 'returns decimal_mark based on the current locale' do
expect(subject.lookup(:decimal_mark, nil)).to eq(nil)
end

it 'returns symbol based on the current locale' do
expect(subject.lookup(:symbol, nil)).to eq(nil)
end
end
end
end

0 comments on commit 0ac7cf4

Please sign in to comment.