2

I'm currently trying to translate a timestamp field of a content type, but month names are always in English. I want the following format in English and French:

  • English : 3 November 2016
  • French : 3 novembre 2016

Code 1 (always in English)

# node--content-type.html.twig
{{ node.field_ends_at.value|date("d F Y") }}

Code 2 (always in English)

# Pass trought field display (Structure > Content type > Manage Display > Format Custom (d F Y)
# node--content-type.html.twig
{{ content.field_ends_at }}

What's the best way to handle date formatting and translation?

2
  • The last example works for me. I've got a translated month.
    – ya.teck
    Nov 4, 2016 at 6:33
  • You need to explain how you have translation set up for your site, as it matters here. I just added a language to a site, configured translation for a content type, added a translated for the node, and got it to work, both with the default formatter in the default render array and with {{ content.field_date_time }} in the template.
    – mpdonadio
    Nov 5, 2016 at 18:03

0

Browse other questions tagged or ask your own question.