Translating month and day names in django templates

I would like to print day names and month names in the currently selected language, but django keeps showing them in english even if language selection is working fine.

In my template:

{{ LANGUAGE_CODE }}
{% localize on %}
  {{ day|date:"l" }}
{% endlocalize %}

The result is:

it Friday

I was expecting:

it Venerdì

If I try to show the date with the default format, using this code: {{ day }} , the date format correctly changes depending on the currently selected language, but the day or month names are still not localized..

So for example if english is selected, I get April 25th 2025, while if italian is selected, I get 25th April 2025. Different date format, but April is always in English.

How can i translate day\month names?

This is my settings.py:

USE_I18N = True
USE_L10N = True
USE_TZ = True

If i understand correct the localize this is not, what you want.

Probably, you need the language template tag.

For example this works for me:

    {% load i18n %}
    {% language 'it' %}
    <div id='header'>{{ today|date:"l" }} </div>
    {% endlanguage 'it' %}

As result i see:

<div id="header">Sabato </div>

The today is the datetime-value:

{'today': datetime.now()}

More about language template tag here:

https://docs.djangoproject.com/en/5.1/topics/i18n/translation/#switching-language-in-templates

Use django.utils.formats.date_format in your template:

{% load l10n %}
{{ day|date_format:"l" }}  {# Outputs localized full weekday name #}
{{ day|date_format:"F" }}  {# Outputs localized full month name #}

This uses Django’s date_format which respects the current active language.

The problem is that for some reason that I still need to investigate, the default .po file under env/lib/python3.9/site-packages/django/conf/locale/it/LC_MESSAGES was "corrupted" with all the entries for the day names like this:

#~ msgid "Friday"
#~ msgstr "Venerdì"

Fixing the .po by reinstalling django fixed the issue:

pip uninstall django
pip install django
Back to Top