View Source Expo.Message (expo v0.1.0-beta.6)

Message Structs

Link to this section Summary

Types

key that can be used to identify a message

t()

Functions

Append flag to message

Tells whether the given message has the flag specified

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

Tells whether two messages are the same message according to their msgid.

Get Source Line Number of statement

Link to this section Types

@opaque key()

key that can be used to identify a message

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

Link to this section Functions

Link to this function

append_flag(message, flag)

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

Append flag to message

Keeps the line formatting intact

examples

Examples

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

has_flag?(message, flag)

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

Tells whether the given message has the flag specified

examples

Examples

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

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

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

This function returns a "key" that can be used to uniquely identify a message assuming that no "same" messages 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 messages but where we don't need the whole structs.

examples

Examples

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

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

same?(message1, message2)

View Source
@spec same?(message1 :: t(), message2 :: t()) :: boolean()

Tells whether two messages are the same message according to their msgid.

This function returns true if message1 and message2 are the same message, where "the same" means they have the same msgid or the same msgid and msgid_plural.

examples

Examples

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

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

source_line_number(message, block, default \\ nil)

View Source
@spec source_line_number(
  message :: Expo.Message.Singular.t(),
  block :: Expo.Message.Singular.block(),
  default :: default
) :: non_neg_integer() | default
when default: term()
@spec source_line_number(
  message :: Expo.Message.Plural.t(),
  block :: Expo.Message.Plural.block(),
  default :: default
) :: non_neg_integer() | default
when default: term()

Get Source Line Number of statement

examples

Examples

iex> %Expo.Messages{messages: [message]} = Expo.Po.parse_string!("""
...> msgid "foo"
...> msgstr "bar"
...> """)
iex> Expo.Message.source_line_number(message, :msgid)
1