View Source Expo.Translations (expo v0.1.0-beta.4)
Translation List Struct for mo / po files
Link to this section Summary
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
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")
[]
Rebalances all strings
- All headers (see
Expo.Translation.Singular.rebalance/1
/Expo.Translation.Plural.rebalance/1
) - Put one string per newline of
headers
and add one empty line at start
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"]
}]
}