Basque date declination

Hello everyone,

I need some guidance on fixing Basque (Euskara) date localization. Our grammar requires conditional logic that Django’s static formats.py file doesn’t support.

Here is a clear example of the problem:

  • Current Django Output: 2025ko urriaren 11a

  • Correct Grammatical Form: 2025eko urriaren 11

There are two errors here based on conditional rules:

  1. Year Suffix: It should be 2025eko. The suffix changes based on the last sound of the year number. Years ending in a consonant sound (like 2025, bost) must use -eko, while the current output -ko is for years ending in a vowel (like 2024, lau).

  2. Day Article: It should be 11. The -a article should not be added to numbers that already end in the vowel ‘a’. The number 11 in Basque is hamaika, so adding another -a (hamaika-a) is grammatically wrong.

The core issue is that we can’t add if/else logic into the formats.py file to handle these rules.

My question is: How have other languages with similar context-sensitive grammar solved this in Django?

I’m sure Basque isn’t the only language with this challenge. Any advice or examples from other localization teams would be a great help.

Thanks!

Hello there!

Maybe in this scenario it would be better to create a shim/facade function to format the dates?

from django.utils import date_format
from django.utils.translation import get_language

def date_format_basque(value):
  return "something"

def my_date_format(value):
  current_lang = get_language()
  if current_lang == "eu" or current_lang == "eus":
    return date_format_basque(value)
  return date_format(value)

# using it

from django.utils import timezone

print(my_date_format(timezone.localdate()))

Let me know if this works for you, or you’re looking to something else.

The Unicode CLDR seems to have sidestepped this by using parentheses: “2025(e)ko” and “11(a)”.

Python (using Babel):

>>> from datetime import date
>>> from babel.dates import format_date
>>> format_date(date(2025, 10, 11), locale="eu_ES", format="long")
'2025(e)ko urriaren 11(a)'
>>> format_date(date(2024, 10, 10), locale="eu_ES", format="long")
'2024(e)ko urriaren 10(a)'

JavaScript (if your browser has the eu-ES locale data available):

Intl.DateTimeFormat("eu-ES", {dateStyle: "long"}).format(new Date(2025, 9, 11))
// "2025(e)ko urriaren 11(a)"
Intl.DateTimeFormat("eu-ES", {dateStyle: "long"}).format(new Date(2024, 9, 10))
// "2024(e)ko urriaren 10(a)"

I’m guessing that’s roughly analogous to something like “October 11st/nd/rd/th” in English. If you’re trying to improve Django’s built-in translations, I’m also guessing that might be the best that can be achieved using gettext.

If you’re trying to solve this for your own app, you may want to look at Mozilla’s Project Fluent. It handles many language features that gettext simply can’t. There are Python bindings and even a django-ftl library available. (I haven’t personally used either.)

1 Like

@medmunds @leandrodesouzadev Thanks for the reply, but we need to go further. We need the ability to use logic in the templates. We may have to change the system