Cover letters: the date is a fixed \"j F Y\", ungrammatical in Polish, Spanish, Hungarian and more #387

Closed
opened 2026-10-01 10:46:19 +00:00 by tiagoagueda · 0 comments
Owner

Found on 2026-09-29 in a read-only review of postulo at 95348908d, by reading the letter theme and rendering its date format under seventeen of the offered languages.

Checked again on 2026-10-01 against main at 0a5cad587: still present. The code is now at documents/rendering.py:421-430 (letter_values); the theme and the lint are unchanged.

The letter theme prints its date with {% now "j F Y" %}. Since #223 the render runs inside translation.override(document_language(letter)), so the month is in the letter's language, but the order and grammar are still English's. F is the month's stand-alone name. Polish, Czech, Ukrainian, Croatian, Lithuanian and Finnish use another form of the name in a date. The pattern also drops the Spanish, Portuguese and Catalan "de", the German and Danish dot after the day, and the year-first order of Hungarian, Lithuanian and Latvian. The {{ date }} placeholder uses DATE_FORMAT, so a letter that uses it prints one date spelled two ways.

  • Where: templates/documents/themes/base_letter.html:37; compare documents/rendering.py:447-456 (letter_values, which builds {{ date }} with formats.date_format(timezone.localdate(), "DATE_FORMAT")); tests/test_template_lint.py:470-471, where TEMPLATE_DATE matches only |date: and |time:, so the {% now %} tag escaped #225's lint.

  • What happens:

    Language The letter prints The locale's own date
    Polish 30 Wrzesień 2026 30 września 2026
    Spanish 30 septiembre 2026 30 de septiembre de 2026
    Hungarian 30 szeptember 2026 2026. szeptember 30.
    Ukrainian 30 Вересень 2026 30 вересня 2026 р.
    Finnish 30 syyskuu 2026 30. syyskuuta 2026
    German 30 September 2026 30. September 2026

    An English letter that uses {{ date }} in its body says "30 September 2026" at the top and "30 Sep 2026" below.

  • Why it matters: the date sits at the top of the one document an employer reads. #223 item 1 named this very line, and its fix changed the language of the date but not its format.

  • Fix:

    • Pass the placeholder's own value into the theme context (letter_values already computes it inside the override) and print that in base_letter.html, so the letter carries one date spelled one way.
    • If letters should spell the month out, add a named long format per locale under config/formats/ (in Django, E gives the month form a date uses) rather than a literal.
    • Extend the lint to {% now "…" %}.

Related to #223 (closed), whose item 1 named this line, and #225 (closed), whose lint does not see the {% now %} tag.

Done when

  • tests/test_links_and_letters.py: a letter in Polish renders its date as formats.date_format(day, "DATE_FORMAT") under pl (or the named long format), and the date at the top equals the value of {{ date }}.
  • tests/test_template_lint.py rejects a literal format in {% now %}.
Found on 2026-09-29 in a read-only review of postulo at 95348908d, by reading the letter theme and rendering its date format under seventeen of the offered languages. Checked again on 2026-10-01 against `main` at `0a5cad587`: still present. The code is now at `documents/rendering.py:421-430` (`letter_values`); the theme and the lint are unchanged. The letter theme prints its date with `{% now "j F Y" %}`. Since #223 the render runs inside `translation.override(document_language(letter))`, so the month is in the letter's language, but the order and grammar are still English's. `F` is the month's stand-alone name. Polish, Czech, Ukrainian, Croatian, Lithuanian and Finnish use another form of the name in a date. The pattern also drops the Spanish, Portuguese and Catalan "de", the German and Danish dot after the day, and the year-first order of Hungarian, Lithuanian and Latvian. The `{{ date }}` placeholder uses `DATE_FORMAT`, so a letter that uses it prints one date spelled two ways. - **Where:** `templates/documents/themes/base_letter.html:37`; compare `documents/rendering.py:447-456` (`letter_values`, which builds `{{ date }}` with `formats.date_format(timezone.localdate(), "DATE_FORMAT")`); `tests/test_template_lint.py:470-471`, where `TEMPLATE_DATE` matches only `|date:` and `|time:`, so the `{% now %}` tag escaped #225's lint. - **What happens:** | Language | The letter prints | The locale's own date | | --- | --- | --- | | Polish | 30 Wrzesień 2026 | 30 września 2026 | | Spanish | 30 septiembre 2026 | 30 de septiembre de 2026 | | Hungarian | 30 szeptember 2026 | 2026. szeptember 30. | | Ukrainian | 30 Вересень 2026 | 30 вересня 2026 р. | | Finnish | 30 syyskuu 2026 | 30. syyskuuta 2026 | | German | 30 September 2026 | 30. September 2026 | An English letter that uses `{{ date }}` in its body says "30 September 2026" at the top and "30 Sep 2026" below. - **Why it matters:** the date sits at the top of the one document an employer reads. #223 item 1 named this very line, and its fix changed the language of the date but not its format. - **Fix:** - Pass the placeholder's own value into the theme context (`letter_values` already computes it inside the override) and print that in `base_letter.html`, so the letter carries one date spelled one way. - If letters should spell the month out, add a named long format per locale under `config/formats/` (in Django, `E` gives the month form a date uses) rather than a literal. - Extend the lint to `{% now "…" %}`. Related to #223 (closed), whose item 1 named this line, and #225 (closed), whose lint does not see the `{% now %}` tag. ## Done when - `tests/test_links_and_letters.py`: a letter in Polish renders its date as `formats.date_format(day, "DATE_FORMAT")` under `pl` (or the named long format), and the date at the top equals the value of `{{ date }}`. - `tests/test_template_lint.py` rejects a literal format in `{% now %}`.
tiagoagueda added this to the 0.6.0 milestone 2026-10-01 10:46:19 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Postulo/postulo#387
No description provided.