woocommerce-ios
woocommerce-ios copied to clipboard
RTL currencies displaying the currency symbol and "-" (minus) incorrectly
Quick report to investigate further, we seem to display the - symbol, for example for discounts or refunds in the incorrect place when RTL is set as per store settings. Along with this, we display the symbol inconsistently left or right to the amount depending on the case.
Even though the language is read from right to left, the numerical and financial contexts such as prices, especially involving arithmetic symbols, maintain a left-to-right order.
Some current examples:
| Discounts | Refunds |
|---|---|
| Fails | |
|---|---|
| :no_entry_sign: | Please add a feature label to this issue. e.g. 'feature: stats' |
Generated by :no_entry_sign: dangerJS
Just had a quick look at this, seems like one way to do it is the use of the unicode marker "\u{200E}" ref: https://stackoverflow.com/a/31744355
So e.g:
Text(minusSign + discountAmount)
Should become:
Text(minusSign + "\u{200E}" + discountAmount)
Or actually using NumberFormatter might work:
if let discountAmount = discountDetailsViewModel.finalAmountString, let discountNumber = Double(discountAmount) {
let formatter = NumberFormatter()
formatter.numberStyle = .decimal
if let formattedString = formatter.string(from: NSNumber(value: -discountNumber)) {
Text(formattedString)
.foregroundColor(Color(uiColor: .withColorStudio(.green, shade: .shade50)))
}
}
using NumberFormatter might work
That sounds good, I'd say we should rely on a NumberFormatter solution for consistency across different views/models, reusability, and easy testing.