MishkaSlug.Messages (Mishka Slug v0.0.1)

Copy Markdown View Source

The messages a site admin can see, translated in the locale of the calling process.

MishkaSlug.slugify/2 returns atoms such as {:error, :empty} and never a text; this module turns those reasons into sentences for forms. Every text is looked up in the mishka_slug domain of gettext_backend/0.

Summary

Functions

Returns the message for a MishkaSlug.slugify/2 error reason.

Returns the Gettext backend in use: the :gettext_backend of the :mishka_slug application config, or MishkaSlug.Gettext.

Returns the message for a value that is not a string.

Functions

error(arg1)

@spec error(MishkaSlug.reason()) :: String.t()

Returns the message for a MishkaSlug.slugify/2 error reason.

Examples

iex> MishkaSlug.Messages.error(:empty)
"has no letters or digits to make a slug from"

iex> MishkaSlug.Messages.error(:no_allowed_script)
"uses letters or digits that the site languages do not allow in a slug"

gettext_backend()

@spec gettext_backend() :: module()

Returns the Gettext backend in use: the :gettext_backend of the :mishka_slug application config, or MishkaSlug.Gettext.

not_a_string()

@spec not_a_string() :: String.t()

Returns the message for a value that is not a string.

Examples

iex> MishkaSlug.Messages.not_a_string()
"is not a string value"