View Source Expo.Translation (expo v0.1.0-beta.5)

Translation Structs

Link to this section Summary

Types

key that can be used to identify a translation

t()

Functions

Append flag to translation

Tells whether the given translation has the flag specified

Returns a "key" that can be used to identify a translation.

Tells whether two translations are the same translation according to their msgid.

Link to this section Types

@opaque key()

key that can be used to identify a translation

@type msgctxt() :: String.t()
@type msgid() :: [String.t()]
@type msgstr() :: [String.t()]

Link to this section Functions

Link to this function

append_flag(translation, flag)

View Source
@spec append_flag(translation :: t(), flag :: String.t()) :: t()

Append flag to translation

Keeps the line formatting intact

examples

Examples

iex> translation = %Expo.Translation.Singular{msgid: [], msgstr: [], flags: []}
iex> Expo.Translation.append_flag(translation, "foo")
%Expo.Translation.Singular{msgid: [], msgstr: [], flags: [["foo"]]}
Link to this function

has_flag?(translation, flag)

View Source
@spec has_flag?(translation :: t(), flag :: String.t()) :: boolean()

Tells whether the given translation has the flag specified

examples

Examples

iex> Expo.Translation.has_flag?(%Expo.Translation.Singular{msgid: [], msgstr: [], flags: [["foo"]]}, "foo")
true

iex> Expo.Translation.has_flag?(%Expo.Translation.Singular{msgid: [], msgstr: [], flags: [["foo"]]}, "bar")
false
@spec key(translation :: t()) :: key()

Returns a "key" that can be used to identify a translation.

This function returns a "key" that can be used to uniquely identify a translation assuming that no "same" translations exist; for what "same" means, look at the documentation for same?/2.

The purpose of this function is to be used in situations where we'd like to group or sort translations but where we don't need the whole structs.

examples

Examples

iex> t1 = %Expo.Translation.Singular{msgid: ["foo"], msgstr: []}
iex> t2 = %Expo.Translation.Singular{msgid: ["", "foo"], msgstr: []}
iex> Expo.Translation.key(t1) == Expo.Translation.key(t2)
true

iex> t1 = %Expo.Translation.Singular{msgid: ["foo"], msgstr: []}
iex> t2 = %Expo.Translation.Singular{msgid: ["bar"], msgstr: []}
iex> Expo.Translation.key(t1) == Expo.Translation.key(t2)
false
Link to this function

same?(translation1, translation2)

View Source
@spec same?(translation1 :: t(), translation2 :: t()) :: boolean()

Tells whether two translations are the same translation according to their msgid.

This function returns true if translation1 and translation2 are the same translation, where "the same" means they have the same msgid or the same msgid and msgid_plural.

examples

Examples

iex> t1 = %Expo.Translation.Singular{msgid: ["foo"], msgstr: []}
iex> t2 = %Expo.Translation.Singular{msgid: ["", "foo"], msgstr: []}
iex> Expo.Translation.same?(t1, t2)
true

iex> t1 = %Expo.Translation.Singular{msgid: ["foo"], msgstr: []}
iex> t2 = %Expo.Translation.Singular{msgid: ["bar"], msgstr: []}
iex> Expo.Translation.same?(t1, t2)
false