Automattic / wp-calypso

The JavaScript and API powered WordPress.com
https://developer.wordpress.com
GNU General Public License v2.0
12.41k stars 1.99k forks source link

Negative currencies put their sign on the wrong side in RTL #71657

Open sirbrillig opened 1 year ago

sirbrillig commented 1 year ago

Switching the browser to use RTL text direction (eg: by running document.dir = 'rtl' in the console) reverses the symbols around formatted prices, like the currency symbol. However, if the number is negative, the negative sign (-) should always (I think?) appear on the left side of the number. There are ways to mitigate this, described more in https://github.com/Automattic/wp-calypso/pull/71387#issuecomment-1370423405

sirbrillig commented 1 year ago

Just to copy from the other issue,

This works correctly from the BIDI algorithm point of view since the minus sign has weak directionality and with base RTL direction it'd be incorrectly put to the right of the numbers. The easiest way to fix it would be to explicitly wrap the minus sign and all the numbers in an LTR run, like <bdo dir="ltr">-140.00</bdo> €, or use some other approach from https://www.w3.org/International/questions/qa-bidi-unicode-controls.

michaeldcain commented 1 year ago

From planning:

On the front-end, since we're consolidating behind formatCurrency, we should add an additional method that generates the HTML string and then update it wherever we're using formatCurrency. Since this bug has likely always been around, it's not likely high priority, but could be dealt with while doing other i18n currency updates.