[FIX #4848] ui, i18n: Replace currency indicator with ~
Signed-off-by: Goran Jovic <goranjovic@gmail.com>
This commit is contained in:
parent
375515b04f
commit
06bb8c6348
|
@ -389,74 +389,83 @@
|
|||
(translation (subs locale 0 2))
|
||||
fallback)))
|
||||
|
||||
(defn format-currency [value currency-code]
|
||||
(.addTier2Support goog.i18n.currency)
|
||||
(defn format-currency
|
||||
([value currency-code]
|
||||
(format-currency value currency-code true))
|
||||
([value currency-code currency-symbol?]
|
||||
(.addTier2Support goog.i18n.currency)
|
||||
(let [currency-code-to-nfs-map {"ZAR" (.-NumberFormatSymbols_af goog.i18n)
|
||||
"ETB" (.-NumberFormatSymbols_am goog.i18n)
|
||||
"EGP" (.-NumberFormatSymbols_ar goog.i18n)
|
||||
"DZD" (.-NumberFormatSymbols_ar_DZ goog.i18n)
|
||||
"AZN" (.-NumberFormatSymbols_az goog.i18n)
|
||||
"BYN" (.-NumberFormatSymbols_be goog.i18n)
|
||||
"BGN" (.-NumberFormatSymbols_bg goog.i18n)
|
||||
"BDT" (.-NumberFormatSymbols_bn goog.i18n)
|
||||
"EUR" (.-NumberFormatSymbols_br goog.i18n)
|
||||
"BAM" (.-NumberFormatSymbols_bs goog.i18n)
|
||||
"USD" (.-NumberFormatSymbols_en goog.i18n)
|
||||
"CZK" (.-NumberFormatSymbols_cs goog.i18n)
|
||||
"GBP" (.-NumberFormatSymbols_cy goog.i18n)
|
||||
"DKK" (.-NumberFormatSymbols_da goog.i18n)
|
||||
"CHF" (.-NumberFormatSymbols_de_CH goog.i18n)
|
||||
"AUD" (.-NumberFormatSymbols_en_AU goog.i18n)
|
||||
"CAD" (.-NumberFormatSymbols_en_CA goog.i18n)
|
||||
"INR" (.-NumberFormatSymbols_en_IN goog.i18n)
|
||||
"SGD" (.-NumberFormatSymbols_en_SG goog.i18n)
|
||||
"MXN" (.-NumberFormatSymbols_es_419 goog.i18n)
|
||||
"IRR" (.-NumberFormatSymbols_fa goog.i18n)
|
||||
"PHP" (.-NumberFormatSymbols_fil goog.i18n)
|
||||
"ILS" (.-NumberFormatSymbols_he goog.i18n)
|
||||
"HRK" (.-NumberFormatSymbols_hr goog.i18n)
|
||||
"HUF" (.-NumberFormatSymbols_hu goog.i18n)
|
||||
"AMD" (.-NumberFormatSymbols_hy goog.i18n)
|
||||
"IDR" (.-NumberFormatSymbols_id goog.i18n)
|
||||
"ISK" (.-NumberFormatSymbols_is goog.i18n)
|
||||
"JPY" (.-NumberFormatSymbols_ja goog.i18n)
|
||||
"GEL" (.-NumberFormatSymbols_ka goog.i18n)
|
||||
"KZT" (.-NumberFormatSymbols_kk goog.i18n)
|
||||
"KHR" (.-NumberFormatSymbols_km goog.i18n)
|
||||
"KRW" (.-NumberFormatSymbols_ko goog.i18n)
|
||||
"KGS" (.-NumberFormatSymbols_ky goog.i18n)
|
||||
"CDF" (.-NumberFormatSymbols_ln goog.i18n)
|
||||
"LAK" (.-NumberFormatSymbols_lo goog.i18n)
|
||||
"MKD" (.-NumberFormatSymbols_mk goog.i18n)
|
||||
"MNT" (.-NumberFormatSymbols_mn goog.i18n)
|
||||
"MDL" (.-NumberFormatSymbols_mo goog.i18n)
|
||||
"MYR" (.-NumberFormatSymbols_ms goog.i18n)
|
||||
"MMK" (.-NumberFormatSymbols_my goog.i18n)
|
||||
"NOK" (.-NumberFormatSymbols_nb goog.i18n)
|
||||
"NPR" (.-NumberFormatSymbols_ne goog.i18n)
|
||||
"PLN" (.-NumberFormatSymbols_pl goog.i18n)
|
||||
"BRL" (.-NumberFormatSymbols_pt goog.i18n)
|
||||
"RON" (.-NumberFormatSymbols_ro goog.i18n)
|
||||
"RUB" (.-NumberFormatSymbols_ru goog.i18n)
|
||||
"RSD" (.-NumberFormatSymbols_sh goog.i18n)
|
||||
"LKR" (.-NumberFormatSymbols_si goog.i18n)
|
||||
"ALL" (.-NumberFormatSymbols_sq goog.i18n)
|
||||
"SEK" (.-NumberFormatSymbols_sv goog.i18n)
|
||||
"TZS" (.-NumberFormatSymbols_sw goog.i18n)
|
||||
"THB" (.-NumberFormatSymbols_th goog.i18n)
|
||||
"TRY" (.-NumberFormatSymbols_tr goog.i18n)
|
||||
"UAH" (.-NumberFormatSymbols_uk goog.i18n)
|
||||
"PKR" (.-NumberFormatSymbols_ur goog.i18n)
|
||||
"UZS" (.-NumberFormatSymbols_uz goog.i18n)
|
||||
"VND" (.-NumberFormatSymbols_vi goog.i18n)
|
||||
"CNY" (.-NumberFormatSymbols_zh goog.i18n)
|
||||
"HKD" (.-NumberFormatSymbols_zh_HK goog.i18n)
|
||||
"TWD" (.-NumberFormatSymbols_zh_TW goog.i18n)}
|
||||
nfs (or (get currency-code-to-nfs-map currency-code)
|
||||
(.-NumberFormatSymbols_en goog.i18n))]
|
||||
(set! (.-NumberFormatSymbols goog.i18n)
|
||||
(if currency-symbol?
|
||||
nfs
|
||||
(-> nfs
|
||||
(js->clj :keywordize-keys true)
|
||||
;; Remove any currency symbol placeholders in the pattern
|
||||
(update-in [:CURRENCY_PATTERN] #(string/replace % #"\s*¤\s*" ""))
|
||||
clj->js)))
|
||||
(.format
|
||||
(new goog.i18n.NumberFormat (.-CURRENCY goog.i18n.NumberFormat.Format) currency-code)
|
||||
value))))
|
||||
|
||||
(def currency-code-to-nfs-map
|
||||
{"ZAR" (.-NumberFormatSymbols_af goog.i18n)
|
||||
"ETB" (.-NumberFormatSymbols_am goog.i18n)
|
||||
"EGP" (.-NumberFormatSymbols_ar goog.i18n)
|
||||
"DZD" (.-NumberFormatSymbols_ar_DZ goog.i18n)
|
||||
"AZN" (.-NumberFormatSymbols_az goog.i18n)
|
||||
"BYN" (.-NumberFormatSymbols_be goog.i18n)
|
||||
"BGN" (.-NumberFormatSymbols_bg goog.i18n)
|
||||
"BDT" (.-NumberFormatSymbols_bn goog.i18n)
|
||||
"EUR" (.-NumberFormatSymbols_br goog.i18n)
|
||||
"BAM" (.-NumberFormatSymbols_bs goog.i18n)
|
||||
"USD" (.-NumberFormatSymbols_en goog.i18n)
|
||||
"CZK" (.-NumberFormatSymbols_cs goog.i18n)
|
||||
"GBP" (.-NumberFormatSymbols_cy goog.i18n)
|
||||
"DKK" (.-NumberFormatSymbols_da goog.i18n)
|
||||
"CHF" (.-NumberFormatSymbols_de_CH goog.i18n)
|
||||
"AUD" (.-NumberFormatSymbols_en_AU goog.i18n)
|
||||
"CAD" (.-NumberFormatSymbols_en_CA goog.i18n)
|
||||
"INR" (.-NumberFormatSymbols_en_IN goog.i18n)
|
||||
"SGD" (.-NumberFormatSymbols_en_SG goog.i18n)
|
||||
"MXN" (.-NumberFormatSymbols_es_419 goog.i18n)
|
||||
"IRR" (.-NumberFormatSymbols_fa goog.i18n)
|
||||
"PHP" (.-NumberFormatSymbols_fil goog.i18n)
|
||||
"ILS" (.-NumberFormatSymbols_he goog.i18n)
|
||||
"HRK" (.-NumberFormatSymbols_hr goog.i18n)
|
||||
"HUF" (.-NumberFormatSymbols_hu goog.i18n)
|
||||
"AMD" (.-NumberFormatSymbols_hy goog.i18n)
|
||||
"IDR" (.-NumberFormatSymbols_id goog.i18n)
|
||||
"ISK" (.-NumberFormatSymbols_is goog.i18n)
|
||||
"JPY" (.-NumberFormatSymbols_ja goog.i18n)
|
||||
"GEL" (.-NumberFormatSymbols_ka goog.i18n)
|
||||
"KZT" (.-NumberFormatSymbols_kk goog.i18n)
|
||||
"KHR" (.-NumberFormatSymbols_km goog.i18n)
|
||||
"KRW" (.-NumberFormatSymbols_ko goog.i18n)
|
||||
"KGS" (.-NumberFormatSymbols_ky goog.i18n)
|
||||
"CDF" (.-NumberFormatSymbols_ln goog.i18n)
|
||||
"LAK" (.-NumberFormatSymbols_lo goog.i18n)
|
||||
"MKD" (.-NumberFormatSymbols_mk goog.i18n)
|
||||
"MNT" (.-NumberFormatSymbols_mn goog.i18n)
|
||||
"MDL" (.-NumberFormatSymbols_mo goog.i18n)
|
||||
"MYR" (.-NumberFormatSymbols_ms goog.i18n)
|
||||
"MMK" (.-NumberFormatSymbols_my goog.i18n)
|
||||
"NOK" (.-NumberFormatSymbols_nb goog.i18n)
|
||||
"NPR" (.-NumberFormatSymbols_ne goog.i18n)
|
||||
"PLN" (.-NumberFormatSymbols_pl goog.i18n)
|
||||
"BRL" (.-NumberFormatSymbols_pt goog.i18n)
|
||||
"RON" (.-NumberFormatSymbols_ro goog.i18n)
|
||||
"RUB" (.-NumberFormatSymbols_ru goog.i18n)
|
||||
"RSD" (.-NumberFormatSymbols_sh goog.i18n)
|
||||
"LKR" (.-NumberFormatSymbols_si goog.i18n)
|
||||
"ALL" (.-NumberFormatSymbols_sq goog.i18n)
|
||||
"SEK" (.-NumberFormatSymbols_sv goog.i18n)
|
||||
"TZS" (.-NumberFormatSymbols_sw goog.i18n)
|
||||
"THB" (.-NumberFormatSymbols_th goog.i18n)
|
||||
"TRY" (.-NumberFormatSymbols_tr goog.i18n)
|
||||
"UAH" (.-NumberFormatSymbols_uk goog.i18n)
|
||||
"PKR" (.-NumberFormatSymbols_ur goog.i18n)
|
||||
"UZS" (.-NumberFormatSymbols_uz goog.i18n)
|
||||
"VND" (.-NumberFormatSymbols_vi goog.i18n)
|
||||
"CNY" (.-NumberFormatSymbols_zh goog.i18n)
|
||||
"HKD" (.-NumberFormatSymbols_zh_HK goog.i18n)
|
||||
"TWD" (.-NumberFormatSymbols_zh_TW goog.i18n)})
|
||||
|
||||
(def custom-nfs (currency-code-to-nfs-map currency-code))
|
||||
(set! (.-NumberFormatSymbols goog.i18n) (if custom-nfs custom-nfs (.-NumberFormatSymbols_en goog.i18n)))
|
||||
(.format
|
||||
(new goog.i18n.NumberFormat (.-CURRENCY goog.i18n.NumberFormat.Format) currency-code)
|
||||
value))
|
||||
|
|
|
@ -68,7 +68,8 @@
|
|||
(-> balance-total-value
|
||||
(money/with-precision 2)
|
||||
str
|
||||
(i18n/format-currency (:code currency))))
|
||||
(i18n/format-currency (:code currency) false)
|
||||
(->> (str "~"))))
|
||||
"...")))
|
||||
|
||||
(re-frame/reg-sub :prices-loading?
|
||||
|
|
Loading…
Reference in New Issue