Hi everyone,
I'm rendering dynamic content using JavaScript and it is in English for one email delivery. I want to use same JavaScript for content that should be in another language.
For example, I'm displaying month name dynamically in email subject as well as email body in English. I want to display the same in French. I'm newbie with ACM. Can anyone help me how I can do that?
I'm using following snippet for email subject for EN -
<%= formatDate(new Date(), "%Bl") %>
And following snippet for email body for EN -
<%
function daysInMonth(today) {
return new Date(today.getFullYear(), today.getMonth()+1, 0).getDate();
}
var today = new Date();
%>
<%= daysInMonth(today) %> <%= formatDate (today, "%Bl") %>, <%= formatDate (today, "%4Y") %>
I want to display the month's name in French in subject as well as email body.
English and French email deliveries are independent so no condition is required.
Solved! Go to Solution.
try this
Last day of the month is: <% function daysInMonth(today) { return new Date(today.getFullYear(), today.getMonth(), 0).getDate(); } function month_fr(today){ var monthFr = ["Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Aout", "Septembre", "Octobre","Novembre","Décembre"]; var thisMonthFr = monthFr[today.getMonth()]; return thisMonthFr.toString(); } var today = new Date(); %> <%= daysInMonth(today) %> <%= month_fr(today) %>, <%= formatDate (today, "%4Y") %>
Hi ,
One way is to use personalization block. You need to predefined text over there with different language you want to use based on some conditions and then you can use your defined personalization block in email delivery.
For more information on how to use personalization block please refer below link :
Also, another way is - within email delivery you can create conditional content , where you'd specify a rule according to the recipient's preferred language, or country
I hope this helps.
Thanks,
Kapil
Hi Kapil,
Thank you for your reply.
I have seen this video and this helped me understand how to use blocks.
I'm having 2 different deliveries as per language preference so there isn't use of conditional statement. But I'm trying to figure out how to use JS specific code so that I could have month's name in French in email body as well as subject.
JS Code I pasted above worked in a simple HTML but it doesn't work in ACM as it doesn't support toLocale. Can you please help with that?
Hi David,
Thank you for the reply. Isn't it possible to do this without using any external libraries?
I tried to use the following code, but it didn't work out:
Last day of the month is: <% function daysInMonth(today) { return new Date(today.getFullYear(), today.getMonth(), 0).getDate(); } function month_fr(today){
var monthFr:["Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Aout", "Septembre", "Octobre","Novembre","Décembre"];
var thisMonthFr = monthFr[today.getMonth()];
return thisMonthFr.toString();
} var today = new Date(); %> <%= daysInMonth(today) %> <%= month_fr(today) %>, <%= formatDate (today, "%4Y") %>
Can you please tell me what might be the issue ?
try this
Last day of the month is: <% function daysInMonth(today) { return new Date(today.getFullYear(), today.getMonth(), 0).getDate(); } function month_fr(today){ var monthFr = ["Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Aout", "Septembre", "Octobre","Novembre","Décembre"]; var thisMonthFr = monthFr[today.getMonth()]; return thisMonthFr.toString(); } var today = new Date(); %> <%= daysInMonth(today) %> <%= month_fr(today) %>, <%= formatDate (today, "%4Y") %>
This worked. I noticed the difference and what was the issue. Thank you
David's answer helped me.
Great! Thanks for letting us know.
Views
Replies
Total Likes
Views
Likes
Replies