View Source Expo.Translation.Singular (expo v0.1.0-beta.3)

Struct for non-plural translations

Link to this section Summary

Link to this section Types

@type t() :: %Expo.Translation.Singular{
  comments: [String.t()],
  extracted_comments: [String.t()],
  flags: [[String.t()]],
  msgctxt: Expo.Translation.msgctxt() | nil,
  msgid: Expo.Translation.msgid(),
  msgstr: Expo.Translation.msgstr(),
  obsolete: boolean(),
  previous_msgids: [[String.t()]],
  references: [
    [file :: String.t() | {file :: String.t(), line :: pos_integer()}]
  ]
}

Link to this section Functions

@spec key(t()) :: {String.t() | nil, String.t()}
@spec rebalance(translation :: t()) :: t()

Rebalances all strings

  • Put one string per newline of msgid / msgstr
  • Put all flags onto one line
  • Put all references onto a separate line

examples

Examples

iex> Expo.Translation.Singular.rebalance(%Expo.Translation.Singular{
...>   msgid: ["", "hello", "\n", "", "world", ""],
...>   msgstr: ["", "hello", "\n", "", "world", ""],
...>   flags: [["one", "two"], ["three"]],
...>   references: [[{"one", 1}, {"two", 2}], ["three"]]
...> })
%Singular{
  msgid: ["hello\n", "world"],
  msgstr: ["hello\n", "world"],
  flags: [["one", "two", "three"]],
  references: [[{"one", 1}], [{"two", 2}], ["three"]]
}