View Source Expo.Message.Plural (expo v0.1.0-beta.6)
Struct for plural messages
Link to this section Summary
Link to this section Types
@type block() :: :msgid | {:msgstr, non_neg_integer()} | :msgctxt | :msgid_plural
@opaque meta()
@type t() :: %Expo.Message.Plural{ __meta__: meta(), comments: [String.t()], extracted_comments: [String.t()], flags: [[String.t()]], msgctxt: Expo.Message.msgctxt() | nil, msgid: Expo.Message.msgid(), msgid_plural: [Expo.Message.msgid()], msgstr: %{required(non_neg_integer()) => Expo.Message.msgstr()}, obsolete: boolean(), previous_messages: [Expo.Message.t()], references: [ [file :: String.t() | {file :: String.t(), line :: pos_integer()}] ] }
Link to this section Functions
Rebalances all strings
- Put one string per newline of
msgid
/msgid_plural
/msgstr
- Put all flags onto one line
- Put all references onto a separate line
examples
Examples
iex> Expo.Message.Plural.rebalance(%Expo.Message.Plural{
...> msgid: ["", "hello", "\n", "", "world", ""],
...> msgid_plural: ["", "hello", "\n", "", "world", ""],
...> msgstr: %{0 => ["", "hello", "\n", "", "world", ""]},
...> flags: [["one", "two"], ["three"]],
...> references: [[{"one", 1}, {"two", 2}], ["three"]]
...> })
%Plural{
msgid: ["hello\n", "world"],
msgid_plural: ["hello\n", "world"],
msgstr: %{0 => ["hello\n", "world"]},
flags: [["one", "two", "three"]],
references: [[{"one", 1}], [{"two", 2}], ["three"]]
}
@spec source_line_number(message :: t(), block :: 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"
...> msgid_plural "foos"
...> msgstr[0] "bar"
...> """)
iex> Expo.Message.Plural.source_line_number(message, :msgid)
1