How to change the currency format?

I need to change currency format on the website.

Currently its displaying like VEB12.98 and I need it like VEB. 12.98 OR it may be 12.98 VEB

Tracked the location to this file under vendor\magento\zendframework1\library\Zend\Locale\Data\fr_FR.xml and I had to change the format in <currencyFormat > tag.

So, How do I extended this in a proper way and implement it ?

I have developed the «Price Format» extension for it.

Here’s the “Minimal Spoiler” :innocent:

I have found a way to override and implement this. Below is the order of the code flow.

  • public function formatTxt on module-directory/Model/Currency.php . This function calls toCurrency which in turn calls to
  • public function toCurrency on zendframework1/library/Zend/Currency.php

when you find the function, you will see $options array variable which contains all the necessary info’s for formatting the price values. Below is the var_dump of $options.
array(12) { ["position"]=> int(16) ["script"]=> NULL ["format"]=> NULL ["display"]=> int(2) ["precision"]=> int(2) ["name"]=> string(9) "US Dollar" ["currency"]=> string(3) "USD" ["symbol"]=> string(1) "$" ["locale"]=> string(5) "en_GB" ["value"]=> int(0) ["service"]=> NULL ["tag"]=> string(11) "Zend_Locale" }

So for moving the currency symbols you can override

public function formatPrecision with DI.xml
<preference for="Magento\Directory\Model\Currency" type="Yourpack\Custom\Model\Currency" />

and pass the options array with necessary values.

For eg: $options['position'] = 16 will move the currency symbol to the right of the currency value (16.24$)
Likewise pass the necessary array options to override.