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

Types

t()

The type for this struct.

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

Link to this function

%Expo.Messages{}

View Source (struct)

The struct to represent a list of messages.

For the type of each field, see t/0.

Link to this function

find(messages, message_to_find)

View Source
@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.

Link to this function

get_header(messages, header_name)

View Source
@spec get_header(t(), String.t()) :: [String.t()]

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")
[]
@spec rebalance(t()) :: t()

Re-balances all strings.

This function does the following things:

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"]
  }]
}