Localize Date Strings with {{dateformat}}
Hi again 🙂
As a part of my teams localization effort, we were hoping to be able to use the
{{dateformat}}
handlebar and pass in the subscriber locale to it in order to get the proper date format (ex MM/dd/yyyy vs dd/MM/yyyy in some countries).
The docs help bot seemed to imply this was supported but looking at the handlerbar implementation, it seems locale information is not currently passed to date-fns
. Is this accurate? Is there a way to accomplish what I am hoping? Thank you in advance!19 Replies
@Shaun, you just advanced to level 1!
Hey @Shaun 👋 adding here some team members that can help us here 🙂 @Emil @Pawan Jain @Gali Baum , can you assist?
While I'm investigating the matter,
As a workaround, you might consider adding the locale as a property to your subscriber model and then using conditional statements to render different date formats based on the locale.
For example:
However, this approach requires you to handle the logic for each locale manually within your templates.
Hi @Shaun, we don' t have that currently within the translations feature. We do have an handlebar function, but not one that takes into account the locale.
This should be part of the upcoming release, that includes the formatting by locale
@Shaun Please update us here if we were able to help, if you were expecting something else / more, let us know 🙂
As of the next release - this is how you would use a date formatting.
In the translation file, for example:
In the editor:
where the date can be a string or a variable you send in the payload as
{date: new Date() }
The result from this example
@Shaun is that the direction of what you were looking for?
Yes, that seems to give me a way to handle this 🙂 I will give that a shot, thank you!
It will be part of the next release:) it’s not there yet 😉
Oh I see, thank you! What is the best way to keep up to date when this functionality will be available?
@Dima Grossman @Paweł T. do we have an estimate on when the translations alpha version will be released ?
somewhere at the end of this week or next week
@Shaun it has been released in v.0.23.0 🙂
@Gali Baum is this also supposed to work for emails? I am trying to set it up and it displays an error in the preview...
Ping @Gali Baum @Pawan Jain ?
Hi @jvinga , it should work, what is the error you are getting?
Also, try setting a value for the date in the payload of the preview