Internationalization helpers for calendar labels, day names, month names, and date/time formatting.
Provides default English translations with full override support via a translations map. Consumers can either:
- Pass a
translationsmap to override specific labels - Use Gettext in their own app and pass translated strings directly
Day numbering
Uses ISO day numbering: 1 = Monday, 7 = Sunday.
Examples
# Default English
I18n.day_name(1)
#=> "Monday"
# With custom translations
translations = %{day_names: %{1 => "Lundi", 2 => "Mardi", ...}}
I18n.day_name(1, translations)
#=> "Lundi"
# Short names
I18n.day_name_short(1)
#=> "Mon"
Summary
Functions
Returns the full day name for an ISO day number (1-7).
Returns the narrow day name (1 letter).
Returns the abbreviated day name (3 letters).
Formats a date for display in list/agenda views.
Formats a time value for display.
Formats a title string for the calendar header based on view mode and date.
Returns a translated label string.
Returns the full month name.
Returns the abbreviated month name.
Returns ordered full day names for a week.
Returns ordered narrow day names for a week.
Returns ordered day names for a week, starting from the given week start day.
Types
@type translations() :: %{ optional(:day_names) => %{required(1..7) => String.t()}, optional(:day_names_short) => %{required(1..7) => String.t()}, optional(:day_names_narrow) => %{required(1..7) => String.t()}, optional(:month_names) => %{required(1..12) => String.t()}, optional(:month_names_short) => %{required(1..12) => String.t()}, optional(:labels) => %{required(atom()) => String.t()} }
Functions
@spec day_name(1..7, translations()) :: String.t()
Returns the full day name for an ISO day number (1-7).
@spec day_name_narrow(1..7, translations()) :: String.t()
Returns the narrow day name (1 letter).
@spec day_name_short(1..7, translations()) :: String.t()
Returns the abbreviated day name (3 letters).
@spec format_date(Date.t(), translations()) :: String.t()
Formats a date for display in list/agenda views.
Examples
iex> I18n.format_date(~D[2026-04-15])
"Wed, Apr 15"
Formats a time value for display.
Options
format—:h24(default) or:h12
Examples
iex> I18n.format_time(~T[14:30:00])
"14:30"
iex> I18n.format_time(~T[14:30:00], format: :h12)
"2:30 PM"
Formats a title string for the calendar header based on view mode and date.
Examples
iex> I18n.format_title(:month, ~D[2026-04-15])
"April 2026"
iex> I18n.format_title(:week, ~D[2026-04-15])
"Apr 13 – 19, 2026"
iex> I18n.format_title(:day, ~D[2026-04-15])
"Wednesday, April 15, 2026"
iex> I18n.format_title(:year, ~D[2026-04-15])
"2026"
@spec label(atom(), translations(), map()) :: String.t()
Returns a translated label string.
Supports interpolation with a bindings map.
Examples
iex> I18n.label(:today)
"Today"
iex> I18n.label(:more, %{}, %{count: 5})
"+5 more"
@spec month_name(1..12, translations()) :: String.t()
Returns the full month name.
@spec month_name_short(1..12, translations()) :: String.t()
Returns the abbreviated month name.
@spec ordered_day_names(1..7, translations()) :: [String.t()]
Returns ordered full day names for a week.
@spec ordered_day_names_narrow(1..7, translations()) :: [String.t()]
Returns ordered narrow day names for a week.
@spec ordered_day_names_short(1..7, translations()) :: [String.t()]
Returns ordered day names for a week, starting from the given week start day.
Examples
iex> I18n.ordered_day_names_short(1)
["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
iex> I18n.ordered_day_names_short(7)
["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]