View Source Expo.Messages (expo v1.1.0)
A struct that represents lists of Expo.Message.Singular
and Expo.Message.Plural
structs for MO and PO files.
All fields in the struct are public. See %Expo.Messages{}
.
Summary
Functions
The struct to represent a list of messages.
Finds a given message_to_find
in a list of messages
.
Gets a header by name.
Re-balances all strings.
Types
@type t() :: %Expo.Messages{ file: nil | Path.t(), headers: [String.t()], messages: [Expo.Message.t()], top_comments: [[String.t()]] }
The type for this struct.
Functions
The struct to represent a list of messages.
For the type of each field, see t/0
.
@spec find([Expo.Message.t()] | t(), Expo.Message.t()) :: Expo.Message.t() | nil
Finds a given message_to_find
in a list of messages
.
Equality between messages is checked using Expo.Message.same?/2
.
Returns nil
if message_to_find
is not found.
Gets a header by name.
The name of the header is case-insensitive.
Examples
iex> messages = %Expo.Messages{headers: ["Language: en_US\n"], messages: []}
iex> Expo.Messages.get_header(messages, "language")
["en_US"]
iex> messages = %Expo.Messages{headers: ["Language: en_US\n"], messages: []}
iex> Expo.Messages.get_header(messages, "invalid")
[]
Re-balances all strings.
This function does the following things:
Re-balances all headers (see
Expo.Message.Singular.rebalance/1
andExpo.Message.Plural.rebalance/1
)Puts one string per newline of
headers
and add one empty line at start
Examples
iex> Expo.Messages.rebalance(%Expo.Messages{
...> headers: ["", "hello", "\n", "", "world", ""],
...> messages: [%Expo.Message.Singular{
...> msgid: ["", "hello", "\n", "", "world", ""],
...> msgstr: ["", "hello", "\n", "", "world", ""]
...> }]
...> })
%Expo.Messages{
headers: ["", "hello\n", "world"],
messages: [%Expo.Message.Singular{
msgid: ["hello\n", "world"],
msgstr: ["hello\n", "world"]
}]
}