Define date.formats.short_with_year for every locale

Merged
GA
2mo ago
+141-1

Problem

date.formats.short_with_year existed in 7 of the 118 config/locales/defaults/*.yml files (en, ca, fr, pl, ru, tr, uk). With config.i18n.fallbacks on, the other 111 borrowed English "%b %d, %Y": month first, abbreviated in the locale's own language. A German user saw 5 January 2027 as "Jan 05, 2027".

The format is used for other-year dates in Bills (due labels, All bills table, the bill page, payment history, Needs review), the period picker (Period) and the recurring transaction pickers.

Found in the #3901 review, where it was declined as out of scope.

Change

Each locale that lacked the key gets one short_with_year line at the end of its date.formats block:

  • 10 copied verbatim from open translation PRs, with the same quotes and the same position after short_month_year, so those merges land the same line: #3681 (de, zh-TW), #3683 (es, it, pt-PT), #3688 (nl, pt-BR) and #3690 (hu, vi, zh-CN).
  • 97 derived from the locale's own date.formats.long: %B becomes %b, and the weekday plus its separator is dropped (es-419, es-AR, es-CL, es-CO, es-CR, es-EC, es-MX, es-NI, es-PA, es-PE, es-US, es-VE, gl, id, km).
  • 4 picked by hand, since their long has no %B: ja "%Y年%m月%d日" (long without the weekday), ko and sl (long as is), and ug "%Y-%m-%d" (its own long; it has no month name to abbreviate).

German now renders " 5. Jan 2027".

For translators

The rule gives two awkward results, where a case suffix in long ends up glued onto the abbreviated month:

  • fi: %d. %bta %Y renders "05. tammita 2027".
  • eu: %Y(e)ko %bk %e renders "2027(e)ko Urtk 5".

Both still beat the English fallback, but a native speaker should pick a better value.

Tests

  • test/i18n_test.rb fails if any defaults/*.yml locale lacks the format. The locale list comes from the files, and each is checked with I18n.t(..., fallback: false, default: nil), because I18n.exists? and a plain I18n.t consult fallbacks and would pass anyway.
  • A second test asserts I18n.l(Date.new(2027, 1, 5), format: :short_with_year, locale: :de) == " 5. Jan 2027".
  • i18n_test.rb now requires test_helper. Run on its own, the file loaded only the gems' built-in locales (en and ru), so any I18n.t with another locale raised I18n::InvalidLocale.
  • The new tests failed before the locale change and pass after it.
  • Full bin/rails test: 10431 runs, 0 failures, 1 error. The error is ReportsControllerTest third-currency, which fails on the 1st of the month on main too and is fixed by #3902.
  • RuboCop and Brakeman are clean.

Screenshots

A German user on All bills, with the clock set to 10 December 2026. The December bill uses :short either way; the three 2027 dates use :short_with_year.

BeforeAfter
Before: Jan 05, 2027After: 5. Jan 2027

Values per locale

Each row shows the format and how it renders 5 January 2027. "long" means derived from that locale's date.formats.long.

All 111 locales
LocaleFormat5 Jan 2027Source
af%d %b %Y05 Jan 2027long
ar%e %b، %Y5 يناير، 2027long
az%d %b %Y05 Yan 2027long
be%-d %b %Y5 Сту 2027long
bg%d %b %Y05 ян. 2027long
bn%e %b %Y5 জানুয়ারি 2027long
bs%e. %b %Y.5. jan 2027.long
cs%d. %b %Y05. Led 2027long
cy%d %b %Y05 Ion 2027long
da%e. %b %Y5. jan 2027long
de%e. %b %Y5. Jan 2027open PR
de-AT%e. %b %Y5. Jän 2027long
de-CH%e. %b %Y5. Jan 2027long
de-DE%e. %b %Y5. Jan 2027long
dz%d %b %Y05 ཟླཝ་དང་པ 2027long
el%e %b %Y5 Ιαν 2027long
el-CY%e %b %Y5 Ιαν 2027long
en-AU%d %b, %Y05 Jan, 2027long
en-CA%b %d, %YJan 05, 2027long
en-CY%d %b, %Y05 Jan, 2027long
en-GB%d %b, %Y05 Jan, 2027long
en-IE%d %b, %Y05 Jan, 2027long
en-IN%d %b %Y05 Jan 2027long
en-NZ%d %b, %Y05 Jan, 2027long
en-TT%d %b %Y05 Jan 2027long
en-US%b %d, %YJan 05, 2027long
en-ZA%d %b %Y05 Jan 2027long
eo%e %b %Y5 jan. 2027long
es%-d de %b de %Y5 de ene de 2027open PR
es-419%d de %b de %Y05 de ene de 2027long
es-AR%d de %b de %Y05 de ene de 2027long
es-CL%d de %b de %Y05 de ene de 2027long
es-CO%d de %b de %Y05 de ene de 2027long
es-CR%d de %b de %Y05 de ene de 2027long
es-EC%-d de %b de %Y5 de ene de 2027long
es-ES%d de %b de %Y05 de ene de 2027long
es-MX%d de %b de %Y05 de ene de 2027long
es-NI%d de %b de %Y05 de ene de 2027long
es-PA%-d de %b de %Y5 de ene de 2027long
es-PE%d de %b del %Y05 de ene del 2027long
es-US%d de %b de %Y05 de ene de 2027long
es-VE%d de %b de %Y05 de ene de 2027long
et%d. %b %Y05. jaan. 2027long
eu%Y(e)ko %bk %e2027(e)ko Urtk 5long
fa%e %b %Y5 ژانویه 2027long
fi%d. %bta %Y05. tammita 2027long
fr-CA%d %b %Y05 jan. 2027long
fr-CH%-d %b %Y5 jan. 2027long
fr-FR%-d %b %Y5 jan. 2027long
fy%e %b %Y5 jan 2027long
gd%d %b %Y05 Faoi 2027long
gl%e de %b de %Y5 de Xan de 2027long
he%e ב%b, %Y5 בינו, 2027long
hi%d %b %Y05 जन 2027long
hi-IN%d %b %Y05 Jan 2027long
hr%e. %b %Y.5. sij. 2027.long
hu%Y. %b %d.2027. jan. 05.open PR
id%d %b %Y05 Jan 2027long
is%e. %b %Y5. jan 2027long
it%d %b %Y05 gen 2027open PR
it-CH%d %b %Y05 Gen 2027long
ja%Y年%m月%d日2027年01月05日by hand
ka%d %b %Y05 იანვ 2027long
kk%-d %b %Y5 қаң. 2027long
kmទី%e ខែ%b ឆ្នាំ%Yទី 5 ខែមករា ឆ្នាំ2027long
kn%d %b %Y05 Jan 2027long
ko%Y년 %m월 %d일2027년 01월 05일by hand
lb%e. %b %Y5. Jan 2027long
lo%e %b %Y5 ມ.ກ 2027long
lt%Y m. %b %d d.2027 m. Sau 05 d.long
lv%Y. gada %e. %b2027. gada 5. Janvlong
mg%e %b %Y5 jan. 2027long
mk%b %e, %YЈан 5, 2027long
ml%d %b, %Y05 ജനു., 2027long
mn%Y %b %d2027 1 сар 05long
mr-IN%d %b %Y05 जाने 2027long
ms%d %b, %Y05 Jan, 2027long
nb%e. %b %Y5. jan 2027long
ne%d %b %Y05 जन. 2027long
nl%e %b %Y5 Jan 2027open PR
nn%e. %b %Y5. jan 2027long
ocLo %e %b de %YLo 5 gen de 2027long
or%b %d, %Yଜାନୁ 05, 2027long
pa%d %b %Y05 ਜਨ 2027long
pt%d de %b de %Y05 de jan de 2027long
pt-BR%d %b %Y05 jan 2027open PR
pt-PT%d %b %Y05 jan 2027open PR
rm%e. %b %Y5. schan 2027long
ro%d %b %Y05 ian 2027long
sc%d %b %Y05 ghe 2027long
sk%d. %b %Y05. Jan 2027long
sl%d. %b %Y05. jan 2027by hand
sq%d %b, %Y05 Jan, 2027long
sr%b %e, %YЈан 5, 2027long
st%d %b %Y05 Phe 2027long
sv%e %b %Y5 jan 2027long
sv-FI%e %b %Y5 jan 2027long
sv-SE%e %b %Y5 jan 2027long
sw%e %b, %Y5 Jan, 2027long
ta%d %b %Y05 ஜன 2027long
te%d %b %Y05 Jan 2027long
th%d %b %Y05 ม.ค. 2027long
tlika-%d ng %b, %Yika-05 ng Ene, 2027long
tt%-d %b %Y5 гыйн. 2027long
ug%Y-%m-%d2027-01-05by hand
ur%d %b، %Y05 جنوری، 2027long
uz%d %b %Y05 yan. 2027long
vi%d %b, %Y05 Thg 1, 2027open PR
wo%d %b, %Y05 Jan, 2027long
zh-CN%Y年%m月%d日2027年01月05日open PR
zh-TW%Y年%m月%d日2027年01月05日open PR

Summary by CodeRabbit

  • New Features

    • Added localized short date formats that include the year across supported languages and regions, following each locale’s conventions.
    • Updated the Turkish date format to avoid padding single-digit days.
  • Tests

    • Added coverage for availability in every locale, locale-specific formatting, and spacing for single-digit days.