PhoenixKitStaff.L10n (PhoenixKitStaff v0.2.0)

Copy Markdown View Source

Tiny locale-aware date/time formatting helpers used by the staff UI.

Unlike Calendar.strftime(d, "%b %d, %Y"), the output of these helpers is safe to translate: the three-letter month labels and the surrounding string template all go through Gettext, so a German locale produces 15. Jan 2025 (or whatever the translator wrote) instead of a hardcoded English ordering.

The function bodies intentionally list every month as a separate gettext/1 call so the string-extraction task picks up all 12 labels into the .pot file. Don't collapse them into a map-based lookup.

Summary

Functions

Formats a Date/DateTime as Mon DD, YYYY. Returns nil for nil.

Formats as Mon DD (no year). Useful for near-term dates.

Short 3-letter month name, translated (Jan, Feb, ...).

Functions

format_date(dt)

@spec format_date(Date.t() | DateTime.t() | NaiveDateTime.t() | nil) ::
  String.t() | nil

Formats a Date/DateTime as Mon DD, YYYY. Returns nil for nil.

format_month_day(dt)

@spec format_month_day(Date.t() | DateTime.t() | nil) :: String.t() | nil

Formats as Mon DD (no year). Useful for near-term dates.

short_month(int)

@spec short_month(1..12) :: String.t()

Short 3-letter month name, translated (Jan, Feb, ...).