Struct rspolib::POEntry

source ·
pub struct POEntry {
Show 14 fields pub msgid: String, pub msgstr: Option<String>, pub msgid_plural: Option<String>, pub msgstr_plural: Vec<String>, pub msgctxt: Option<String>, pub obsolete: bool, pub comment: Option<String>, pub tcomment: Option<String>, pub occurrences: Vec<(String, String)>, pub flags: Vec<String>, pub previous_msgid: Option<String>, pub previous_msgid_plural: Option<String>, pub previous_msgctxt: Option<String>, pub linenum: usize,
}
Expand description

PO file entry representing a message

This struct contains all the information that is stored in PO files.

PO entries can 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.

The previous_msgid and previous_msgid_plural fields are used to store the previous msgid and msgid_plural values when the entry is obsolete.

The previous_msgctxt field is used to store the previous msgctxt value when the entry is obsolete.

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

§obsolete: bool

the entry is marked as obsolete

§comment: Option<String>

generated comments for machines

§tcomment: Option<String>

generated comments for translators

§occurrences: Vec<(String, String)>

files and lines from which the translations are taken

§flags: Vec<String>

flags indicating the state, i.e. fuzzy

§previous_msgid: Option<String>

previous untranslated string

§previous_msgid_plural: Option<String>

previous untranslated string for plural form

§previous_msgctxt: Option<String>

previous context

§linenum: usize

line number in the file or content

Implementations§

source§

impl POEntry

source

pub fn new(linenum: usize) -> Self

Creates a new POEntry

It just creates the entry with a given line number. This function is used by the parser to initialize new entries. Use the From traits instead to initialize POEntrys from strings.

source

pub fn fuzzy(&self) -> bool

Returns true the entry has the fuzzy flag

source

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

Convert to string with a given wrap width

Trait Implementations§

source§

impl Clone for POEntry

source§

fn clone(&self) -> POEntry

Returns a copy 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 POEntry

source§

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

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

impl Default for POEntry

source§

fn default() -> POEntry

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

impl Display for POEntry

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 POEntry

source§

fn from(s: &str) -> Self

Converts to this type from the input type.
source§

impl From<(&str, &str)> for POEntry

source§

fn from((msgid, msgstr): (&str, &str)) -> Self

Converts to this type from the input type.
source§

impl From<usize> for POEntry

source§

fn from(linenum: usize) -> Self

Converts to this type from the input type.
source§

impl Merge for POEntry

source§

fn merge(&mut self, other: Self)

Merge a struct with another of the same type
source§

impl MsgidEotMsgctxt for POEntry

source§

fn msgid_eot_msgctxt(&self) -> String

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

impl PartialEq<POEntry> for POEntry

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Translated for POEntry

source§

impl StructuralPartialEq for POEntry

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere T: Clone,

§

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 Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

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

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.