View Source Expo.Translation.Plural (expo v0.1.0-beta.4)

Struct for plural translations

Link to this section Summary

Functions

Rebalances all strings

Link to this section Types

@type t() :: %Expo.Translation.Plural{
  comments: [String.t()],
  extracted_comments: [String.t()],
  flags: [[String.t()]],
  msgctxt: Expo.Translation.msgctxt() | nil,
  msgid: Expo.Translation.msgid(),
  msgid_plural: [Expo.Translation.msgid()],
  msgstr: %{required(non_neg_integer()) => Expo.Translation.msgstr()},
  obsolete: boolean(),
  previous_msgid_plurals: [[String.t()]],
  previous_msgids: [[String.t()]],
  references: [
    [file :: String.t() | {file :: String.t(), line :: pos_integer()}]
  ]
}

Link to this section Functions

@spec rebalance(translation :: t()) :: t()

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.Translation.Plural.rebalance(%Expo.Translation.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"]]
}