SOLVED

Re: Velocity: month (of date) in local language

Go to solution
rpaauw
Level 1

Velocity: month (of date) in local language

I have read a good post of @SanfordWhiteman regarding showing dates in all kind of ways in emails. In our instance we send emails in 3 different languages (English, German and Dutch). As I am new to Velocity scripting, I'm trying, without success yet, to show the month of the date in the correct language.

I would like to show October in the Dutch language (= oktober) for example. This should be done through a DateTool request, but a cannot figure out how. Does anyone know?

 

#set( $defaultTimeZone = $date.getTimeZone().getTimeZone("Europe/Amsterdam") )
#set( $defaultLocale = $date.getLocale() )
#set( $calNow = $date.getCalendar() )
#set( $ret = $calNow.setTimeZone($defaultTimeZone) )
#set( $calConst = $field.in($calNow) )
#set( $ISO8601DateOnly = "yyyy-MM-dd" )
#set( $ISO8601DateTime = "yyyy-MM-dd'T'HH:mm:ss" )
#set( $ISO8601DateTimeWithSpace = "yyyy-MM-dd HH:mm:ss" )
#set( $ISO8601DateTimeWithMillisUTC = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" )
#set( $ISO8601DateTimeWithMillisTZ = "yyyy-MM-dd'T'HH:mm:ss.SSSZ" )

${date.format(
  "d MMMM yyyy",
  $calNow,
  $defaultLocale,
  $defaultTimeZone
)}

 

  

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity: month (of date) in local language

Right now you haven’t done anything to change the locale.

 

You have to instantiate a new locale object:

#set( $leadLocale = $convert.toLocale("nl_NL") )

 

Then you can use it:

${date.format(
  "d MMMM yyyy",
  $calNow,
  $leadLocale,
  $defaultTimeZone
)}

View solution in original post

2 REPLIES 2
SanfordWhiteman
Level 10 - Community Moderator

Re: Velocity: month (of date) in local language

Right now you haven’t done anything to change the locale.

 

You have to instantiate a new locale object:

#set( $leadLocale = $convert.toLocale("nl_NL") )

 

Then you can use it:

${date.format(
  "d MMMM yyyy",
  $calNow,
  $leadLocale,
  $defaultTimeZone
)}
rpaauw
Level 1

Re: Velocity: month (of date) in local language

Thanks Sanford, this helps me out!