pub struct MOEntry {
pub msgid: String,
pub msgstr: Option<String>,
pub msgid_plural: Option<String>,
pub msgstr_plural: Vec<String>,
pub msgctxt: Option<String>,
}Expand description
MO file entry representing a message
Unlike PO files, MO files contain only the content needed to translate a program at runtime, so this is struct optimized as saves much more memory than POEntry.
MO entries ieally contain msgstr or the fields
msgid_plural and msgstr_plural as not being None.
The logic would be:
- If
msgstris notNone, then the entry is a translation of a singular form. - If
msgid_pluralis notNone, then the entry is a translation of a plural form contained inmsgstr_plural.
Fields§
§msgid: Stringuntranslated string
msgstr: Option<String>translated string
msgid_plural: Option<String>untranslated string for plural form
msgstr_plural: Vec<String>translated strings for plural form
msgctxt: Option<String>context
Implementations§
Source§impl MOEntry
impl MOEntry
pub fn new( msgid: String, msgstr: Option<String>, msgid_plural: Option<String>, msgstr_plural: Vec<String>, msgctxt: Option<String>, ) -> MOEntry
Sourcepub fn to_string_with_wrapwidth(&self, wrapwidth: usize) -> String
pub fn to_string_with_wrapwidth(&self, wrapwidth: usize) -> String
Convert to a string representation with a given wrap width
Sourcepub fn cmp_by(&self, other: &Self, options: &EntryCmpByOptions) -> Ordering
pub fn cmp_by(&self, other: &Self, options: &EntryCmpByOptions) -> Ordering
Compare the current entry with other entry
You can disable some comparison options by setting the corresponding
field in options to false. See EntryCmpByOptions.
Trait Implementations§
Source§impl MsgidEotMsgctxt for MOEntry
impl MsgidEotMsgctxt for MOEntry
Source§fn msgid_eot_msgctxt(&self) -> String
fn msgid_eot_msgctxt(&self) -> String
msgid + (optionally: EOT + msgctxt)Source§impl Translated for MOEntry
impl Translated for MOEntry
Source§fn translated(&self) -> bool
fn translated(&self) -> bool
Returns true if the entry is translated
Really, MO files has only translated entries, but this function is here to be consistent with the PO implementation and to be used when manipulating MOEntry directly.