Masu.Messages (Masu v0.7.0)

Copy Markdown View Source

The words of a grid, in English: its labels, its menus' items, the filters' operators, what it announces to screen readers.

messages on Masu.Components.data_grid/1 replaces any of them, by key. To show a grid in another language, give it every key, from your translations, and its locale (which formats numbers and dates):

<.data_grid id="orders" rows={@orders} messages={MyAppWeb.Masu.messages()} locale={@locale}>

def messages do
  %{
    "search" => gettext("Search"),
    "empty" => gettext("No rows"),
    ...
  }
end

{label}, {count}, {first}, {last}, {done} and {total} in a message are replaced by the grid, and stay as they are in a translation. defaults/0 has every key, so a test can check that none is left in English:

assert Map.keys(MyAppWeb.Masu.messages()) -- Map.keys(Masu.Messages.defaults()) == []
assert Map.keys(Masu.Messages.defaults()) -- Map.keys(MyAppWeb.Masu.messages()) == []

Summary

Functions

Every word of a grid, by key, in English.

Functions

defaults()

@spec defaults() :: %{required(String.t()) => String.t()}

Every word of a grid, by key, in English.