metabase icon indicating copy to clipboard operation
metabase copied to clipboard

Offer symbol_native currency format as an option

Open gitstart opened this issue 2 years ago • 3 comments

Fixes #23786

Before submitting the PR, please make sure you do the following
  • [x] If you're attempting to fix a translation issue, please submit your changes to our POEditor project instead of opening a PR.

Tests

  • [x] Run the frontend and Cypress end-to-end tests with yarn lint && yarn test)
  • [x] If there are changes to the backend codebase, run the backend tests with clojure -X:dev:test
  • [x] Sign the Contributor License Agreement (unless it's a tiny documentation change).

Demo

Screenshot from 2022-07-15 18-00-41

https://www.loom.com/share/93f2124aadb544bbadfdc78c13b844a5

gitstart avatar Jul 25 '22 07:07 gitstart

Codecov Report

Merging #24253 (d225c63) into master (adf4518) will decrease coverage by 0.00%. The diff coverage is 50.00%.

@@            Coverage Diff             @@
##           master   #24253      +/-   ##
==========================================
- Coverage   65.19%   65.19%   -0.01%     
==========================================
  Files        2830     2830              
  Lines       85692    85697       +5     
  Branches    10815    10817       +2     
==========================================
- Hits        55868    55866       -2     
- Misses      25391    25396       +5     
- Partials     4433     4435       +2     
Flag Coverage Δ
back-end 85.82% <ø> (-0.01%) :arrow_down:
front-end 46.36% <50.00%> (-0.01%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
frontend/src/metabase/lib/formatting/numbers.tsx 81.57% <0.00%> (-1.09%) :arrow_down:
...src/metabase/visualizations/lib/settings/column.js 69.14% <33.33%> (-1.19%) :arrow_down:
frontend/src/metabase/lib/formatting/currency.js 100.00% <100.00%> (ø)
src/metabase/task/sync_databases.clj 77.08% <0.00%> (-2.78%) :arrow_down:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov[bot] avatar Jul 25 '22 07:07 codecov[bot]

Issue submitter here - thanks so much for working on this everyone!

Can I suggest that the UI option label be "Local Symbol" instead of "Symbol Native"?

The term "native" is fairly well-understood for devs, but it sort of has a different meaning in general English - and in many areas with an indigenous population it has some negative historical usage baggage.

IMHO "local" or "locale" would be clearer.

willbryant avatar Aug 06 '22 20:08 willbryant

Second thing, the code you've changed here makes this option work properly in the column header mode. To make it work in the table cell mode, you need to also make the following code change:

diff --git a/frontend/src/metabase/lib/formatting.js b/frontend/src/metabase/lib/formatting.js
index 3f3c1ee7f6..5b31260a26 100644
--- a/frontend/src/metabase/lib/formatting.js
+++ b/frontend/src/metabase/lib/formatting.js
@@ -99,7 +99,10 @@ export function numberFormatterForOptions(options) {
   return new Intl.NumberFormat("en", {
     style: options.number_style,
     currency: options.currency,
-    currencyDisplay: options.currency_style,
+    currencyDisplay:
+      options.currency_style === "symbol_native"
+        ? "narrowSymbol"
+        : options.currency_style,
     // always use grouping separators, but we may replace/remove them depending on number_separators option
     useGrouping: true,
     minimumIntegerDigits: options.minimumIntegerDigits,

willbryant avatar Aug 07 '22 04:08 willbryant