Changing Locale in Velocity Script (outputting £ instead of $) | Community
Skip to main content
Neil_Robertson6
Level 4
August 4, 2015
Question

Changing Locale in Velocity Script (outputting £ instead of $)

  • August 4, 2015
  • 1 reply
  • 2006 views

Hi,

I am outputting some currency values which are in GBP but by default Marketo will output these values as $ when formatting using the following script:

$number.format("currency",$tokenvalue) or number.currency($tokenvalue)

I can see that the server Locale is "en_US" when using this

#set ( $serverLocale = $number.getLocale() )

But I need programmatic control of this and number.setLocale() doesnt seem to work when adding en_GB.

Anyone had to or managed an output to non US currencies?

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

1 reply

Neil_Robertson6
Level 4
September 7, 2015

Is no one else doing currency outputs other than $?!

Nicholas_Manojl
Level 8
September 8, 2015

I'm not exactly a pro, in fact I'm not even an amateur and I have zero programming/scripting experience, but this is how I'd do it quick and dirty. so I'm actually keen to see a better solution.

#set ( $price = ${lead.number} )

#if ( ${lead.Country} == "United Kingdom" )

#set ( $currency = "£")

#elseif ( ${lead.Country} != "United Kingdom" )

#set ( $currency = "$" )

#end

<p>your offer will be $currency$price</p>

September 8, 2015

Ah, that is how I ended up doing it (sort of).  It's not ideal as you would expect that we can change locale across the board / instance.