From 65d176f533746d463d125573e66d170f78516111 Mon Sep 17 00:00:00 2001 From: Pierre de Lacroix Date: Wed, 4 Oct 2017 00:33:42 +0200 Subject: [PATCH] Fix wrong way to force currency symbol after the amount --- .../darkswarm/filters/localize_currency.js.coffee | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/darkswarm/filters/localize_currency.js.coffee b/app/assets/javascripts/darkswarm/filters/localize_currency.js.coffee index a194e78e7b..37de2759cc 100644 --- a/app/assets/javascripts/darkswarm/filters/localize_currency.js.coffee +++ b/app/assets/javascripts/darkswarm/filters/localize_currency.js.coffee @@ -3,12 +3,12 @@ Darkswarm.filter "localizeCurrency", (currencyConfig)-> (amount) -> # Set country code (eg. "US"). currency_code = if currencyConfig.display_currency then " " + currencyConfig.currency else "" - # Set decimal points, 2 or 0 if hide_cents. + # Set decimal points, 2 or 0 if hide_cents. decimals = if currencyConfig.hide_cents == "true" then 0 else 2 - # Set wether the currency symbol appears first - sign_first = currencyConfig.symbol_position == 'before' + # Set format if the currency symbol should come after the number, otherwise (default) use the locale setting. + format = if currencyConfig.symbol_position == "after" then "%n %u" else undefined # We need to use parseFloat as the amount should come in as a string. amount = parseFloat(amount) # Build the final price string. - I18n.toCurrency(amount, {precision: decimals, unit: currencyConfig.symbol, sign_first: sign_first}) + currency_code + I18n.toCurrency(amount, {precision: decimals, unit: currencyConfig.symbol, format: format}) + currency_code