Struct gettext::ParseOptions
source · pub struct ParseOptions { /* private fields */ }
Expand description
ParseOptions allows setting options for parsing MO catalogs.
Examples
ⓘ
use std::fs::File;
extern crate encoding;
use encoding::all::ISO_8859_1;
let file = File::open("french.mo").unwrap();
let catalog = ParseOptions::new().force_encoding(ISO_8859_1).parse(file).unwrap();
Implementations
sourceimpl ParseOptions
impl ParseOptions
sourcepub fn parse<R: Read>(self, reader: R) -> Result<Catalog, Error>
pub fn parse<R: Read>(self, reader: R) -> Result<Catalog, Error>
Tries to parse the catalog from the given reader using the specified options.
sourcepub fn force_encoding(self, encoding: EncodingRef) -> Self
pub fn force_encoding(self, encoding: EncodingRef) -> Self
Forces a use of a specific encoding when parsing strings from a catalog. If this option is not enabled, the parser tries to use the encoding specified in the metadata or UTF-8 if metadata is non-existent.
sourcepub fn force_plural(self, plural: fn(_: u64) -> usize) -> Self
pub fn force_plural(self, plural: fn(_: u64) -> usize) -> Self
Forces a use of the given plural formula
for deciding the proper plural form for a message.
If this option is not enabled,
the parser uses the default formula
(n != 1
).
Trait Implementations
sourceimpl Default for ParseOptions
impl Default for ParseOptions
sourcefn default() -> ParseOptions
fn default() -> ParseOptions
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl !RefUnwindSafe for ParseOptions
impl Send for ParseOptions
impl Sync for ParseOptions
impl Unpin for ParseOptions
impl !UnwindSafe for ParseOptions
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more