Fakererer.Gettext.Helpers (Fakerer v0.1.0)

Copy Markdown View Source

Helper functions for working with Gettext in Fakererer.

Provides functions to pick random items from Gettext translations, which is the core mechanism for locale-specific fake data.

Summary

Functions

Returns all items from a Gettext translation as a list.

Picks a random item from a Gettext translation.

Picks multiple random items from a Gettext translation.

Functions

all_items(domain, msgid)

@spec all_items(String.t(), String.t()) :: [String.t()]

Returns all items from a Gettext translation as a list.

pick_random(domain, msgid)

@spec pick_random(String.t(), String.t()) :: String.t()

Picks a random item from a Gettext translation.

The translation is expected to be a newline-separated list of items. Falls back to the msgid if no translation is found.

Examples

iex> Fakererer.Gettext.Helpers.pick_random("address", "city_prefix")
"Thị trấn"

pick_random_many(domain, msgid, count)

@spec pick_random_many(String.t(), String.t(), non_neg_integer()) :: [String.t()]

Picks multiple random items from a Gettext translation.