Personalized checkout and custom promotions with Shopify Scripts
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!
Solved! Go to the solution
This is an accepted solution.
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
This is an accepted solution.
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
Thank you Stephen! found a way around it, but will keep this one up my sleeve.
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024