View Source Glific.Settings (Glific v5.1.6)

The Settings context. This includes language for now.

Link to this section Summary

Functions

Returns an %Ecto.Changeset{} for tracking language changes.

Return the count of languages, using the same filter as list_languages

Creates a language.

Deletes a language.

Gets a single language.

Get language from label or shortcode

Get map of ids to locale for translation lookup

Upserts a language based on the unique indexes in the table. If there is a match it returns the existing contact, else it creates a new one

Returns the list of languages.

Get map of localte to ids for easier lookup for json based flow editor

Updates a language.

Link to this section Functions

Link to this function

change_language(language, attrs \\ %{})

View Source
@spec change_language(Glific.Settings.Language.t(), map()) :: Ecto.Changeset.t()

Returns an %Ecto.Changeset{} for tracking language changes.

examples

Examples

iex> change_language(language)
%Ecto.Changeset{data: %Language{}}
Link to this function

count_languages(args \\ %{})

View Source
@spec count_languages(map()) :: integer()

Return the count of languages, using the same filter as list_languages

Link to this function

create_language(attrs \\ %{})

View Source
@spec create_language(map()) ::
  {:ok, Glific.Settings.Language.t()} | {:error, Ecto.Changeset.t()}

Creates a language.

examples

Examples

iex> create_language(%{field: value})
{:ok, %Language{}}

iex> create_language(%{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

delete_language(language)

View Source
@spec delete_language(Glific.Settings.Language.t()) ::
  {:ok, Glific.Settings.Language.t()} | {:error, Ecto.Changeset.t()}

Deletes a language.

examples

Examples

iex> delete_language(language)
{:ok, %Language{}}

iex> delete_language(language)
{:error, %Ecto.Changeset{}}
@spec get_language!(integer()) :: Glific.Settings.Language.t()

Gets a single language.

Raises Ecto.NoResultsError if the Language does not exist.

examples

Examples

iex> get_language!(123)
%Language{}

iex> get_language!(456)
** (Ecto.NoResultsError)
Link to this function

get_language_by_label_or_locale(term)

View Source
@spec get_language_by_label_or_locale(String.t()) :: list()

Get language from label or shortcode

Link to this function

get_language_id_local_map()

View Source
@spec get_language_id_local_map() :: map()

Get map of ids to locale for translation lookup

@spec language_upsert(map()) :: {:ok, Glific.Settings.Language.t()}

Upserts a language based on the unique indexes in the table. If there is a match it returns the existing contact, else it creates a new one

Link to this function

list_languages(args \\ %{})

View Source
@spec list_languages(map()) :: [Glific.Settings.Language.t(), ...]

Returns the list of languages.

examples

Examples

iex> list_languages()
[%Language{}, ...]
@spec locale_id_map() :: %{required(String.t()) => integer()}

Get map of localte to ids for easier lookup for json based flow editor

Link to this function

update_language(language, attrs)

View Source
@spec update_language(Glific.Settings.Language.t(), map()) ::
  {:ok, Glific.Settings.Language.t()} | {:error, Ecto.Changeset.t()}

Updates a language.

examples

Examples

iex> update_language(language, %{field: new_value})
{:ok, %Language{}}

iex> update_language(language, %{field: bad_value})
{:error, %Ecto.Changeset{}}