How can I localize the liquid date filter?

Hi!
Does someone have an idea on how to localize the liquid date filter?

I was hoping that inputing

{{ “Tuesday” | date: “%A” }}

Would output the correct translation of tuesday for the language the user is browsing the site in.

Thanks for your suggestions!

Hi,

Liquid will do that for you, if you use the locale files. E.g.:

In en.default.json you define:

"date_formats": {
    "month_day_year": "%b %d, %Y",
    "weekday": "%A"
  }

And in de.json:

"date_formats": {
    "month_day_year": "%d. %b %Y",
    "weekday": "%A"
  }

You can then do the following:

{{ "2022-05-31" | date: format: 'weekday' }}

If you browse your site in English, you will get:

Tuesday

And in German you will get:

Dienstag

1 Like

Thank you Stephen! found a way around it, but will keep this one up my sleeve.