1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//! [](https://crates.io/crates/rspolib) [](https://pypi.org/project/rspolib) [](https://docs.rs/rspolib) [](https://github.com/mondeja/rspolib/blob/master/python/REFERENCE.md)
//!
//! Port to Rust of the Python library [polib].
//!
//! ## Install
//!
//! ```bash
//! cargo add rspolib
//! ```
//!
//! ## Usage
//!
//! ```rust
//! use rspolib::{pofile, prelude::*};
//!
//! let po = pofile("./tests-data/flags.po").unwrap();
//!
//! for entry in &po.entries {
//! println!("{}", entry.msgid);
//! }
//!
//! po.save("./file.po");
//! ```
//!
//! See the documentation at [docs.rs/rspolib](https://docs.rs/rspolib)
//!
//! ## Python bindings
//!
//! [](https://pypi.org/project/rspolib/#files)
//!
//! - [Quickstart](https://github.com/mondeja/rspolib/tree/master/python#readme)
//! - [Reference](https://github.com/mondeja/rspolib/blob/master/python/REFERENCE.md)
//!
//! [polib]: https://github.com/izimobil/polib
//!
//! ## Quick examples
//!
//! ### Read and save a PO file
//!
//! ```rust
//! use rspolib::{pofile, Save};
//!
//! let file = pofile("tests-data/obsoletes.po").unwrap();
//! for entry in file.translated_entries() {
//! println!("{}", &entry.msgid);
//! }
//! file.save("tests-data/docs/pofile_save.po");
//! ```
//!
//! ### Read and save a MO file
//!
//! ```rust
//! // You can include the prelude to access to all the methods
//! use rspolib::{mofile, prelude::*};
//!
//! let mut file = mofile("tests-data/all.mo").unwrap();
//! for entry in &file.entries {
//! // All entries are translated in MO files
//! println!("{}", entry.msgid);
//! }
//! file.save("tests-data/docs/mofile_save.mo");
//! ```
//!
//! ## Features
//!
//! * Unicode Line Breaking formatting support.
//! * Correct handling of empty and non existent PO fields values.
//! * Detailed error handling parsing PO and MO files.
//! * Custom byte order MO files generation.
//!
//! ## General view
//!
//! * [POFile]s, contains [POEntry]s.
//! * [MOFile]s, contains [MOEntry]s.
//!
//! Items of the same level can be converted between them,
//! for example a [POEntry] can be converted to a [MOEntry] using
//! `MOEntry::from(&POEntry)` because [MOEntry]s implement the
//! [From] trait for &[POEntry].
//!
//! All of the conversions that make sense are implemented for
//! all the structs. For example, to get the representation of a
//! [POFile] just call `to_string()` or to get the binary representation
//! of bytes of a [MOFile] calls `as_bytes()`.
//!
//! [polib]: https://github.com/izimobil/polib
pub use crate;
pub use crate;
pub use crate;
pub use crateMerge;