PhoenixLiveGantt.Utils.I18n (PhoenixLiveGantt v0.1.0)

Copy Markdown View Source

Minimal translation helper for Gantt labels + month names.

Consumers pass a translations map to override the English defaults for the labels the chart actually renders (toolbar buttons, sidebar header, edge indicators, etc.). Anything not overridden falls back to the default English string.

Example

translations = %{
  labels: %{today: "Aujourd'hui", task: "Tâche"},
  month_names_short: %{1 => "Janv", 2 => "Févr", ...}
}

I18n.label(:today, translations)
#=> "Aujourd'hui"

Summary

Functions

Look up a label string by atom key (:today, :task, etc.) and format %{count}-style placeholders against the bindings map.

Short month name (e.g. "Apr") for month number 1-12.

Types

translations()

@type translations() :: %{
  optional(:month_names_short) => %{required(1..12) => String.t()},
  optional(:labels) => %{required(atom()) => String.t()}
}

Functions

label(key, translations \\ %{}, bindings \\ %{})

@spec label(atom(), translations(), map()) :: String.t()

Look up a label string by atom key (:today, :task, etc.) and format %{count}-style placeholders against the bindings map.

month_name_short(month, translations \\ %{})

@spec month_name_short(1..12, translations()) :: String.t()

Short month name (e.g. "Apr") for month number 1-12.