summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Shalamov <alexander.shalamov@mapbox.com>2019-09-02 22:51:37 +0300
committerAlexander Shalamov <alexander.shalamov@mapbox.com>2019-09-04 10:37:50 +0300
commit907aaba93d0c325e98cf91a2651c6f3e1654dedf (patch)
tree5db66403a88014c18ba4342d392482f7e3261988
parent3c5cdf19430c744b86d275f59c83478bafb137f0 (diff)
downloadqtlocation-mapboxgl-907aaba93d0c325e98cf91a2651c6f3e1654dedf.tar.gz
[darwin] Reset number formatter digits for currency style
As we are using singleton formatter, fraction digits must be reset when number formatter is used when initialized for decimal / currency style.
-rw-r--r--platform/darwin/src/string_nsstring.mm4
1 files changed, 4 insertions, 0 deletions
diff --git a/platform/darwin/src/string_nsstring.mm b/platform/darwin/src/string_nsstring.mm
index 096ed2b212..382a2acf33 100644
--- a/platform/darwin/src/string_nsstring.mm
+++ b/platform/darwin/src/string_nsstring.mm
@@ -43,6 +43,10 @@ std::string formatNumber(double number, const std::string& localeId, const std::
numberFormatter.maximumFractionDigits = maxFractionDigits;
numberFormatter.numberStyle = NSNumberFormatterDecimalStyle;
} else {
+ // Reset fraction digits to NSNumberFormatter's default values, so that the
+ // system will choose formatting based on number formatter locale.
+ numberFormatter.minimumFractionDigits = 0;
+ numberFormatter.maximumFractionDigits = 0;
numberFormatter.numberStyle = NSNumberFormatterCurrencyStyle;
}
NSString *formatted = [numberFormatter stringFromNumber:@(number)];