1 | //! Writing to MO files. |
2 | |
3 | mod mo_file_writer; |
4 | |
5 | pub use mo_file_writer::write; |
6 | |
7 | use crate::po_file; |
8 | use crate::po_file::POParseOptions; |
9 | use std::error::Error; |
10 | use std::path::Path; |
11 | |
12 | /// Compile a `.po` file to a `.mo` file. |
13 | pub fn compile_from_po(input_path: &Path, output_path: &Path) -> Result<(), Box<dyn Error>> { |
14 | let parse_options: POParseOptions = POParseOptions { |
15 | message_body_only: true, |
16 | translated_only: true, |
17 | unsafe_utf8_decode: false, |
18 | }; |
19 | let catalog: Catalog = po_file::parse_with_option(input_path, &parse_options)?; |
20 | write(&catalog, output_path)?; |
21 | Ok(()) |
22 | } |
23 | |