Cadastre v0.1.1 Cadastre.Language View Source

Language implementation

Link to this section Summary

Functions

Returns all languages

Return all ids (ISO_639-2)

Returns language name translation for locale

Returns language native name

Returns %Cadastre.Language{} for valid id. Returns nil for invalid id.

Link to this section Types

Link to this type

id()

View Source
id() :: <<_::16>>
Link to this type

t()

View Source
t() :: %Cadastre.Language{id: id(), name: Cadastre.msgid()}

Link to this section Functions

Returns all languages

Examples

iex> Cadastre.Language.all() |> Enum.take(3)
[
  %Cadastre.Language{id: "aa", name: "Afar"},
  %Cadastre.Language{id: "ab", name: "Abkhazian"},
  %Cadastre.Language{id: "af", name: "Afrikaans"}
]

iex> Cadastre.Language.all() |> Enum.count()
141

Return all ids (ISO_639-2)

Examples

iex> Cadastre.Language.ids() |> Enum.take(10)
["aa", "ab", "af", "am", "an", "as", "av", "ba", "be", "bg"]
Link to this function

name(language, locale)

View Source
name(t(), id()) :: String.t()

Returns language name translation for locale

Examples

iex> Cadastre.Language.new("nl") |> Cadastre.Language.name("be")
"галандская"

iex> Cadastre.Language.new("nl") |> Cadastre.Language.name(":)")
"Dutch"

iex> Cadastre.Language.name("something wrong", "be")
nil
Link to this function

native_name(language)

View Source
native_name(t()) :: String.t()

Returns language native name

Examples

iex> Cadastre.Language.new("nl") |> Cadastre.Language.native_name()
"Nederlands"

iex> Cadastre.Language.native_name("something wrong")
nil
Link to this function

new(id)

View Source
new(id() | any()) :: t() | nil

Returns %Cadastre.Language{} for valid id. Returns nil for invalid id.

Examples

iex> Cadastre.Language.new("nl")
%Cadastre.Language{id: "nl", name: "Dutch"}

iex> Cadastre.Language.new("NL")
%Cadastre.Language{id: "nl", name: "Dutch"}

iex> Cadastre.Language.new("xx")
nil