Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Hi,
Is there any way how to get localized/translated Date information within the calendar header (between pager links)? So far there are two replacement patterns being offered but I found that in the calendar-pager.html.twig it's just an object renderred so I can't use neither |t
for translation nor |date()
for formalt filtering.
I'm working with month view created using Views templates module.
Thanks
Comment | File | Size | Author |
---|---|---|---|
#12 | interdiff-7-12.txt | 2.38 KB | Anonymous (not verified) |
#7 | translation_of_the_date-2701413-7.patch | 1.31 KB | sylus |
Comments
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous at XIO commentedThe Calendar Header is rendered separately from the pager, so you don't need the pager template.
The header is part of the view and it's configuration, so you can translate that specific part after translating the full view. In that particular text field, twig syntax is supported, so you could add something like date("m/d/Y") to fit your needs.
Comment #3
andrask CreditAttribution: andrask commentedpjonckiere, can you please explain me step by step how to translate the month names in the header? Sorry for the dumb question, I'm just a simple webdesigner.
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous at XIO commentedAfter re-reading the IS, I notice that I have given the wrong instructions. To change the title in between the pager, you were looking in the right template.
Looking again at the question, I notice that I'm unable to translate that string, even though I'm quite sure that I tested this the previous time I looked at it. I'll have to investigate that.
Comment #5
Anonymous (not verified) CreditAttribution: Anonymous at XIO commentedI started making a step-by-step guide, before realising I couldn't translate it myself, and then forgot to remove this image. This screenshot is no longer relevant.
Comment #6
andrask CreditAttribution: andrask commentedNo update on this issue really? I made a website for a local school and I have to translate the month names seriously. It is live now, and the users don't understand how a simple translation like this can't be done.
Comment #7
sylus CreditAttribution: sylus commentedI think this might be more of a bug in how the $date->format is being called?
I did a quick workaround calling the date.formatter service statically which seemed to fix the issue.
Obviously while not the appropriate solution can hopefully point us in the right direction.
Comment #8
texis CreditAttribution: texis as a volunteer commentedI've tried this patch and it works perfect - even for the Day based view header where name of days is being displayed.
Thanks
TC
Comment #9
AnticoVeneziano CreditAttribution: AnticoVeneziano commentedthank you! patch at #7 works!!!
Comment #10
andrask CreditAttribution: andrask commentedIt works, thank you!
Comment #11
eigentor CreditAttribution: eigentor commentedWhat's necessary to get this RTBC? I am not such a pro coder, but you just changed one line. So for me the patch works to and I'm gonna set it to RTBC, maybe the maintainers will have a look then.
Comment #12
Anonymous (not verified) CreditAttribution: Anonymous at XIO commented> I think this might be more of a bug in how the $date->format is being called?
That function actually doesn't support localisation, see http://php.net/manual/en/datetime.format.php
I think using the dateformatter service is a decent workaround, so let's go with that. Committed and pushed to 8.x-1.x.
On commit, I changed the patch so the service is injected rather than being called using the static method. And a little coding standard thingy. Interdiff of that attached.
Thanks everyone!