Skip to content

Commit

Permalink
Fix JS locale data for release of Money 6.19
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
mamhoff committed Dec 2, 2024
1 parent e6abb7a commit 3676954
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ Spree.formatMoney = function(amount, currency) {
var thousand = Spree.t('currency_delimiter');
var decimal = Spree.t('currency_separator');

return accounting.formatMoney(amount, currencyInfo[0], currencyInfo[1], thousand, decimal, currencyInfo[2]);
return accounting.formatMoney(amount, currencyInfo[0], currencyInfo[1], thousand, decimal, currencyInfo[2]).trim();
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@
JSON.dump(
Spree::Config.available_currencies.map { |c|
format =
if c.symbol == "" || c.symbol_first
if c.format.present?
c.format.gsub("%u", "%s").gsub("%n", "%v")
elsif c.symbol == "" || c.symbol_first
"%s%v"
else
"%v %s"
end

[c.id.to_s.upcase, [
c.symbol || "¤",
c.exponent,
Expand Down

0 comments on commit 3676954

Please sign in to comment.