Struct crowbook_localize::Extractor
[−]
[src]
pub struct Extractor { /* fields omitted */ }
Struct that extracts all messages from source code and can print them
to a .pot
file.
This file can then be used as a starting point to begin translation.
It should be relatively similar to gettext
generated files.
Example
use crowbook_intl::Extractor; let mut extractor = Extractor::new(); extractor.add_messages_from_dir("src/").unwrap(); println!("{}", extractor.generate_pot_file());
Note
This struct only add messages that are considered as needing localization,
that is, the first argument of calls so lformat!
macro.
Methods
impl Extractor
[src]
fn new() -> Extractor
Create a new, empty extractor
fn original_strings<'a>(&'a self) -> &'a HashMap<String, String>
Returns a hashmap mapping the original strings (as used by lformat!
)
to escaped strings. Only contains strings that are different and
must thus be handled.
fn add_messages_from_file<P: AsRef<Path>>(&mut self, file: P) -> Result<()>
Add all the messages contained in a source file
fn add_messages_from_dir<P: AsRef<Path>>(&mut self, dir: P) -> Result<()>
Add messages from all .rs
files contained in a directory
(walks through subdirectories)
fn generate_pot_file(&self) -> String
Generate a pot-like file from the strings extracted from all files (if any)
fn write_pot_file(&mut self, file: &str) -> Result<()>
Write a pot-like file to specified location