Gettext.PO.Translations
Summary
Tells whether a translation was manually entered or generated by Gettext
Finds a given translation in a list of translations
Returns a “key” that can be used to identify a translation
Tells whether two translations are the same translation according to their
msgid
Functions
Specs
autogenerated?(Gettext.PO.translation) :: boolean
Tells whether a translation was manually entered or generated by Gettext.
As of now, a translation is considered autogenerated if it has one or more references.
Examples
iex> t = %Gettext.PO.Translation{msgid: "foo", references: [{"foo.ex", 1}]}
iex> Gettext.PO.Translations.autogenerated?(t)
true
Specs
Finds a given translation in a list of translations.
Equality between translations is checked using same?/2.
Specs
key(Gettext.PO.PluralTranslation.t) :: {binary, binary}
key(Gettext.PO.Translation.t) :: binary
Returns a “key” that can be used to identify a translation.
This function returns a “key” that can be used to uniquely identify a
translation assuming that no “same” translations exist; for what “same”
means, look at the documentation for same?/2.
The purpose of this function is to be used in situations where we’d like to group or sort translations but where we don’t need the whole structs.
Examples
iex> t = %Gettext.PO.Translation{msgid: "foo"}
iex> Gettext.PO.Translations.key(t)
"foo"
iex> t = %Gettext.PO.PluralTranslation{msgid: "foo", msgid_plural: "foos"}
iex> Gettext.PO.Translations.key(t)
{"foo", "foos"}
Specs
same?(Gettext.PO.translation, Gettext.PO.translation) :: boolean
Tells whether two translations are the same translation according to their
msgid.
This function returns true if translation1 and translation2 are the same
translation, where “the same” means they have the same msgid or the same
msgid and msgid_plural.
Examples
iex> t1 = %Gettext.PO.Translation{msgid: "foo", references: [{"foo.ex", 1}]}
iex> t2 = %Gettext.PO.Translation{msgid: "foo", comments: ["# hey"]}
iex> Gettext.PO.Translations.same?(t1, t2)
true