Chime.Messages (Chime v0.1.0-dev)

Copy Markdown View Source

Chime's words, in the app's languages, by the app's own Gettext. Chime ships English, and a template of its words; the app translates them as it translates its own.

{Chime, ..., gettext: MyAppWeb.Gettext}

With :gettext, every word of Chime's (the bell and the feed, the preferences, "Ana and 4 others", the digest's email, the page to unsubscribe) is looked up in the "chime" domain of the app's backend, in its locale of the moment. Copy Chime's template into the app's, and make the languages' files from it:

$ cp deps/chime/priv/gettext/chime.pot priv/gettext/
$ mix gettext.merge priv/gettext

mix gettext.merge makes priv/gettext/<locale>/LC_MESSAGES/chime.po for each of the app's languages, to translate as the app's own. After an upgrade of Chime, copy the template again and merge: the new words come, the translations stay. A word not translated is English.

The labels and descriptions of the config's :categories are looked up in the same domain: add them to the app's chime.po files as more msgids.

The locale

The feed, the bell and the JSON API speak the locale of the request or the LiveView, as the app's own plugs and hooks set it. What a job sends (the email and the channels of a delivery, the digests) speaks the person's :locale (Chime.Recipient): Chime runs it in Gettext.with_locale/3, so the notifier's own gettext calls in its email/3 speak it too.

Summary

Functions

A word of Chime's, in the locale of the moment.

A word of Chime's with a plural, by count.

Functions

t(msgid, bindings \\ %{})

@spec t(String.t(), map() | keyword()) :: String.t()

A word of Chime's, in the locale of the moment.

tn(msgid, plural, count, bindings \\ %{})

@spec tn(String.t(), String.t(), integer(), map() | keyword()) :: String.t()

A word of Chime's with a plural, by count.