[−][src]Struct gettext::Catalog
Catalog represents a set of translation strings parsed out of one MO file.
Methods
impl Catalog
[src]
pub fn empty() -> Self
[src]
Creates an empty catalog.
All the translated strings will be the same as the original ones.
pub fn parse<R: Read>(reader: R) -> Result<Self, Error>
[src]
Parses a gettext catalog from the given binary MO file.
Returns the Err
variant upon encountering an invalid file format
or invalid byte sequence in strings.
Calling this method is equivalent to calling
ParseOptions::new().parse(reader)
.
Examples
use gettext::Catalog; use std::fs::File; let file = File::open("french.mo").unwrap(); let catalog = Catalog::parse(file).unwrap();
pub fn gettext<'a>(&'a self, msg_id: &'a str) -> &'a str
[src]
Returns the singular translation of msg_id
from the given catalog
or msg_id
itself if a translation does not exist.
pub fn ngettext<'a>(
&'a self,
msg_id: &'a str,
msg_id_plural: &'a str,
n: u64
) -> &'a str
[src]
&'a self,
msg_id: &'a str,
msg_id_plural: &'a str,
n: u64
) -> &'a str
Returns the plural translation of msg_id
from the given catalog
with the correct plural form for the number n
of objects.
Returns msg_id if a translation does not exist and n == 1
,
msg_id_plural otherwise.
pub fn pgettext<'a>(&'a self, msg_context: &'a str, msg_id: &'a str) -> &'a str
[src]
Returns the singular translation of msg_id
in the context msg_context
or msg_id
itself if a translation does not exist.
pub fn npgettext<'a>(
&'a self,
msg_context: &'a str,
msg_id: &'a str,
msg_id_plural: &'a str,
n: u64
) -> &'a str
[src]
&'a self,
msg_context: &'a str,
msg_id: &'a str,
msg_id_plural: &'a str,
n: u64
) -> &'a str
Returns the plural translation of msg_id
in the context msg_context
with the correct plural form for the number n
of objects.
Returns msg_id if a translation does not exist and n == 1
,
msg_id_plural otherwise.
Trait Implementations
impl Clone for Catalog
[src]
fn clone(&self) -> Catalog
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for Catalog
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,