Google Tag Manager

Forum Discussion

OomensT's avatar
OomensT
Active Member
2 years ago

Date formatting with correct Locale

Hi, 
I'm trying to add formatting to a datetime field, however if I use formatting that prints weekdays, months fully the English language is always used. Even when the locale of the user is something different.
I can't find how I can pass locale to this date formatting.

Current liquid code:
{{canvas_entry_properties.${date} | date: '%A %d %B %Y - %H:%M'}}

This prints: Monday 07 August 2023 - 08:23,
but should print: Maandag 07 augustus 2023 - 08:23 in locale nl-NL


Documentation on date formatting: https://www.braze.com/docs/user_guide/personalization_and_dynamic_content/liquid/filters/#date-filter

  • Arso's avatar
    Arso
    Specialist

    OomensT Liquid doesn't support date translation. At least, it says so in an article on their blog. They encourage using universal date formats without day and month names. 

    This requires a custom solution that checks the user's locale and swaps all the names of the days and months to the relevant translations on the fly. 

    I found this code on Github that's doing just that. You can add as many languages as you want. However, this only works on Shopify websites in its current format. It requires some adaptation in order for it to work in Braze.