Expo.Composer.Po (expo v0.1.0-beta.1)

Create .po / .pot string from translations

Link to this section Summary

Functions

Dumps a Expo.Translations struct as iodata. This function dumps a Expo.Translations struct (representing a PO file) as iodata, which can later be written to a file or converted to a string with IO.iodata_to_binary/1.

Link to this section Types

@type opts() :: []

Link to this section Functions

Link to this function

compose(translations, opts \\ [])

@spec compose(translations :: Expo.Translations.t(), opts :: opts()) :: iodata()

Dumps a Expo.Translations struct as iodata. This function dumps a Expo.Translations struct (representing a PO file) as iodata, which can later be written to a file or converted to a string with IO.iodata_to_binary/1.

examples

Examples

After running the following code:

iodata = Expo.Exposer.Po.composer %Expo.Translations{
  headers: ["Last-Translator: Jane Doe"],
  translations: [
    %Expo.Translation.Singular{msgid: ["foo"], msgstr: ["bar"], comments: "A comment"}
  ]
}
File.write!("/tmp/test.po", iodata)

the /tmp/test.po file would look like this:

msgid ""
msgstr ""
"Last-Translator: Jane Doe"
# A comment
msgid "foo"
msgstr "bar"