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

Translation List Struct for mo / po files

Link to this section Summary

Functions

Get Header by name (case insensitive)

Rebalances all strings

Link to this section Types

@type t() :: %Expo.Translations{
  file: nil | Path.t(),
  headers: [String.t()],
  top_comments: [[String.t()]],
  translations: [Expo.Translation.t()]
}

Link to this section Functions

Link to this function

get_header(translations, header_name)

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

Get Header by name (case insensitive)

examples

Examples

iex> translations = %Expo.Translations{headers: ["Language: en_US\n"], translations: []}
iex> Expo.Translations.get_header(translations, "language")
["en_US"]

iex> translations = %Expo.Translations{headers: ["Language: en_US\n"], translations: []}
iex> Expo.Translations.get_header(translations, "invalid")
[]
@spec rebalance(translation :: t()) :: t()

Rebalances all strings

examples

Examples

iex> Expo.Translations.rebalance(%Expo.Translations{
...>   headers: ["", "hello", "\n", "", "world", ""],
...>   translations: [%Expo.Translation.Singular{
...>     msgid: ["", "hello", "\n", "", "world", ""],
...>     msgstr: ["", "hello", "\n", "", "world", ""]
...>   }]
...> })
%Expo.Translations{
  headers: ["", "hello\n", "world"],
  translations: [%Expo.Translation.Singular{
    msgid: ["hello\n", "world"],
    msgstr: ["hello\n", "world"]
  }]
}