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

CommentFileSizeAuthor
#12 interdiff-7-12.txt2.38 KBAnonymous (not verified)
#7 translation_of_the_date-2701413-7.patch1.31 KBsylus
#4 2701413.png63.19 KBAnonymous (not verified)
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

texis created an issue. See original summary.

Anonymous’s picture

The 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.

andrask’s picture

pjonckiere, 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.

Anonymous’s picture

Issue summary: View changes
FileSize
63.19 KB

After 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.

Anonymous’s picture

I 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.

andrask’s picture

No 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.

sylus’s picture

Category: Support request » Bug report
FileSize
1.31 KB

I 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.

texis’s picture

I've tried this patch and it works perfect - even for the Day based view header where name of days is being displayed.

Thanks
TC

AnticoVeneziano’s picture

thank you! patch at #7 works!!!

andrask’s picture

It works, thank you!

eigentor’s picture

Status: Active » Reviewed & tested by the community

What'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.

Anonymous’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: +#drupalironcamp
FileSize
2.38 KB

> 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!

  • pjonckiere committed af6ce71 on 8.x-1.x authored by sylus
    Issue #2701413 by sylus, pjonckiere, texis, andrask, AnticoVeneziano,...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.