Skip to content

Override narrow currency symbol for SEK for non-sv locales #285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions data/other/currency/locales/root.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
root:
currencies:
SEK:
narrow_symbol: SEK
2 changes: 2 additions & 0 deletions data/other/currency/locales/sv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ sv:
one: Kiribati dollar
other: Kiribati dollars
symbol: "$"
SEK:
narrow_symbol: "kr"
11 changes: 11 additions & 0 deletions test/worldwide/currency_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ class CurrencyTest < ActiveSupport::TestCase
assert_equal "£", Worldwide.currency(code: "JEP").symbol
end

test "#symbol correctly returns the currency symbol for overridden CLDR SEK currency entries" do
I18n.with_locale(:en) do
assert_equal "SEK", Worldwide.currency(code: "SEK").symbol
end
I18n.with_locale(:sv) do
assert_equal "kr", Worldwide.currency(code: "SEK").symbol
end
end

test "#label returns the translated values of a currency for USD currency iso code in en" do
assert_equal "US dollar", @usd_currency.label(count: 1)
assert_equal "US dollars", @usd_currency.label(count: 2)
Expand Down Expand Up @@ -165,6 +174,8 @@ class CurrencyTest < ActiveSupport::TestCase
[:en, :HKD, 12345, "HK$12,345.00"],
[:"en-AU", :USD, 12.37, "$12.37"],
[:"en-AU", :EUR, 12.37, "€12.37"],
[:en, :SEK, 12345, "SEK12,345.00"],
[:sv, :SEK, 12345, "12 345,00 kr"],
]

data.each do |locale, currency_code, input, expected|
Expand Down
Loading