Struct crowbook_localize::Localizer
[−]
[src]
pub struct Localizer { /* fields omitted */ }
Main struct for initiating localization for a project.
Example
use crowbook_localize::Localizer; let fr = r#" msgid "Hello, {}" msgstr "Bonjour, {}" "#; let es = r#" msgid "Hello, {}" msgstr "Hola, {}" "#; let mut localizer = Localizer::new(); localizer.add_lang("fr", fr).unwrap(); localizer.add_lang("es", es).unwrap(); println!("{}", localizer.generate_macro_file());Run
Methods
impl Localizer
[src]
fn new() -> Localizer
Create a new, empty Localizer
fn add_lang<S: Into<String>>(&mut self, lang: S, s: &str) -> Result<()>
Add a lang to the localizer
Arguments
lang
: the code of the language (e.g. "fr", "en", ...);s
: a string containing localization information. It should be foramtted similarly to gettextmo
files.
fn generate_macro_file(self) -> String
Generate the localization_macros.rs
file.
fn write_macro_file(self, file: &str) -> Result<()>
Write the localization_macros.rs
file to a file.