MOEntry

Struct MOEntry 

Source
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 msgstr is not None, then the entry is a translation of a singular form.
  • If msgid_plural is not None, then the entry is a translation of a plural form contained in msgstr_plural.

Fields§

§msgid: String

untranslated 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

Source

pub fn new( msgid: String, msgstr: Option<String>, msgid_plural: Option<String>, msgstr_plural: Vec<String>, msgctxt: Option<String>, ) -> MOEntry

Source

pub fn to_string_with_wrapwidth(&self, wrapwidth: usize) -> String

Convert to a string representation with a given wrap width

Source

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 Clone for MOEntry

Source§

fn clone(&self) -> MOEntry

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MOEntry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MOEntry

Source§

fn default() -> MOEntry

Returns the “default value” for a type. Read more
Source§

impl Display for MOEntry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<&MOEntry> for POEntry

Source§

fn from(mo_entry: &MOEntry) -> Self

Converts to this type from the input type.
Source§

impl From<&POEntry> for MOEntry

Source§

fn from(entry: &POEntry) -> Self

Generates a MOEntry from a POEntry

Keep in mind that this conversion loss the information that is contained in POEntrys but not in MOEntrys.

Source§

impl From<&str> for MOEntry

Source§

fn from(s: &str) -> Self

Generates a MOEntry from a string as the msgid

Source§

impl Merge for MOEntry

Source§

fn merge(&mut self, other: Self)

Merge a struct with another of the same type
Source§

impl MsgidEotMsgctxt for MOEntry

Source§

fn msgid_eot_msgctxt(&self) -> String

Returns msgid + (optionally: EOT + msgctxt)
Source§

impl PartialEq for MOEntry

Source§

fn eq(&self, other: &MOEntry) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Translated for MOEntry

Source§

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.

Source§

impl StructuralPartialEq for MOEntry

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.