Skip to content

Commit 415d2e7

Browse files
committed
Fix JS locale data for release of Money 6.19
The money gem in its latest iteration added a space between value and unit of the Swiss Franc. Our heuristic in `_js_locale_data.html.erb` can't deal with that, so we add a third branch to it: If the money gem has a format wish, we'll respect it, but replace its abbreviations with the one the `accounting.js` library prefers. (cherry picked from commit f19e6fc)
1 parent f29a29b commit 415d2e7

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

backend/app/assets/javascripts/spree/backend/format_money.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ Spree.formatMoney = function(amount, currency) {
77
var thousand = Spree.t('currency_delimiter');
88
var decimal = Spree.t('currency_separator');
99

10-
return accounting.formatMoney(amount, currencyInfo[0], currencyInfo[1], thousand, decimal, currencyInfo[2]);
10+
return accounting.formatMoney(amount, currencyInfo[0], currencyInfo[1], thousand, decimal, currencyInfo[2]).trim();
1111
}

backend/app/views/spree/admin/shared/_js_locale_data.html.erb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,14 @@
1717
JSON.dump(
1818
Spree::Config.available_currencies.map { |c|
1919
format =
20-
if c.symbol == "" || c.symbol_first
20+
if c.format.present?
21+
c.format.gsub("%u", "%s").gsub("%n", "%v")
22+
elsif c.symbol == "" || c.symbol_first
2123
"%s%v"
2224
else
2325
"%v %s"
2426
end
27+
2528
[c.id.to_s.upcase, [
2629
c.symbol || "¤",
2730
c.exponent,

0 commit comments

Comments
 (0)