Tayori.Messages (Tayori v0.1.0)

Copy Markdown View Source

The words around the news: the button, the panel, the public page and the feeds ("What's new", "Show more"). The entries are the app's own, written in the admin in each language.

The words are here in English, Portuguese, Spanish, French, German, Italian, Dutch and Japanese; a locale with a region (pt-BR, en-GB) takes the words of its language, and another language gets English.

Give other words in the config, by locale or language:

config :tayori, messages: %{"en" => %{"title" => "Changelog"}}

or to a component, as messages. A word may have {n}, which is filled with a count; the keys that end in One and Other are the forms of a count. date is the pattern of a day ({d}, {m}, {y}, {month}), and months the names of the months, separated by commas.

Summary

Functions

A day in words, in the language of the messages.

The words for a locale: the built-in words of its language, then those of the config for the language and for the locale, then overrides.

The keys of the words.

The count of unread entries in words.

Functions

date(messages, at)

@spec date(map(), Date.t() | DateTime.t()) :: String.t()

A day in words, in the language of the messages.

Examples

iex> Tayori.Messages.date(Tayori.Messages.for_locale("en"), ~U[2026-10-20 09:00:00Z])
"20 October 2026"

iex> Tayori.Messages.date(Tayori.Messages.for_locale("pt-PT"), ~D[2026-03-01])
"1 de março de 2026"

iex> Tayori.Messages.date(Tayori.Messages.for_locale("ja"), ~D[2026-03-01])
"2026年3月1日"

for_locale(locale, overrides \\ %{})

@spec for_locale(String.t() | nil, map()) :: %{required(String.t()) => String.t()}

The words for a locale: the built-in words of its language, then those of the config for the language and for the locale, then overrides.

Examples

iex> Tayori.Messages.for_locale("pt-PT")["title"]
"Novidades"

iex> Tayori.Messages.for_locale("sv")["title"]
"What's new"

iex> Tayori.Messages.for_locale("en", %{"title" => "Changelog"})["title"]
"Changelog"

keys()

@spec keys() :: [String.t()]

The keys of the words.

Examples

iex> "title" in Tayori.Messages.keys()
true

unread(messages, n)

@spec unread(map(), non_neg_integer()) :: String.t()

The count of unread entries in words.

Examples

iex> Tayori.Messages.unread(Tayori.Messages.for_locale("en"), 1)
"1 new update"

iex> Tayori.Messages.unread(Tayori.Messages.for_locale("pt"), 3)
"3 novidades"