[][src]Struct carapax_i18n::Catalog

pub struct Catalog { /* fields omitted */ }

Catalog represents a set of translation strings parsed out of one MO file.

Methods

impl Catalog[src]

pub fn parse<R>(reader: R) -> Result<Catalog, Error> where
    R: Read
[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

This example is not tested
use gettext::Catalog;
use std::fs::File;

let file = File::open("french.mo").unwrap();
let catalog = Catalog::parse(file).unwrap();

pub fn gettext(&'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 self,
    msg_id: &'a str,
    msg_id_plural: &'a str,
    n: u64
) -> &'a str
[src]

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.

Currently, the only supported plural formula is n != 1.

pub fn pgettext(&'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 self,
    msg_context: &'a str,
    msg_id: &'a str,
    msg_id_plural: &'a str,
    n: u64
) -> &'a str
[src]

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.

Currently, the only supported plural formula is n != 1.

Trait Implementations

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

impl Send for Catalog

impl Sync for Catalog

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Any for T where
    T: Any

impl<T> Erased for T

impl<T> CloneAny for T where
    T: Clone + Any