View Source Expo.Messages (expo v0.3.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 t/0.

Link to this section Summary

Functions

Finds a given message_to_find in a list of messages.

Get header by name (case insensitive).

Rebalances all strings.

Link to this section Types

@type t() :: %Expo.Messages{
  file: nil | Path.t(),
  headers: [String.t()],
  messages: [Expo.Message.t()],
  top_comments: [[String.t()]]
}

Link to this section Functions

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()]

Get header by name (case insensitive).

examples

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()

Rebalances all strings.

examples

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