Velocity currency formatter | Community
Skip to main content
New Participant
July 21, 2020
Solved

Velocity currency formatter

  • July 21, 2020
  • 1 reply
  • 4513 views

Hi all

 

I'm creating an email script which outputs a currency value based on the person's currency. So, for example, someone might have a value assigned of 1125.13 euros. My script should take the input, localise it by the currency that is selected, and give the output as a string for printing in the email. In the example above, 1125.13 euros would become €1.125,13 - since a comma is the fractional separator and a period is the thousands separator. 

 

I'm getting my formats from here: https://fastspring.com/blog/how-to-format-30-currencies-from-countries-all-over-the-world/. Now while I don't need all of the currencies here, I need a solid dozen of them, and the string formatting gets quite complicated. 

 

I've read about the .currency method under NumberTools - but I want to set the locale. Reading through something like this: https://groups.google.com/forum/#!topic/dotcms/Aax-lKAsWhk I feel that we can't change locale like this in Marketo's scripting....but maybe you can in a similar way to how you can do this with timezones?

 

Any ideas on how to do this? It really doesn't seem great to write complicated substring find and replaces, and then maintain that...

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman

You can instantiate a Locale very simply:

#set( $formatted = $number.format("currency", $amount, $convert.toLocale("de_DE")) )

 

 

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
July 21, 2020

You can instantiate a Locale very simply:

#set( $formatted = $number.format("currency", $amount, $convert.toLocale("de_DE")) )

 

 

New Participant
July 22, 2020

Wow. It really is that easy! Thanks so much Sanford.