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
//! Translation catalogues are key part of any localization infrastructure. They contain the lists
//! of messages from the application, possibly disambiguated with identifiers or contexts, and
//! corresponding translations.
//!
//! Catalogs are usually stored in one of two formats: [Portable Objects (`.po`)][PO], used
//! primarily by [GNU gettext][gettext], and [XML Localisation Interchange File Format
//! (XLIFF)][XLIFF], a more generic OASIS open standard.
//!
//! These formats can be converted to each other, and to and from many others, using
//! [translate-toolkit][tt].
//!
//! [XLIFF] is quite flexible and can be used in different ways, but this library focuses
//! primarily on using it in a way [gettext] and [translate-toolkit][tt] work, namely with separate
//! catalogue for each language.
//!
//! Example:
//! ```rust
//! use pobuilder::PoParser;
//!
//! use std::{env::args, fs::File, io::Result};
//!
//! fn main() -> Result<()> {
//! // Filename
//! let filename = match args().skip(1).next() {
//! Some(v) => v,
//! None => {
//! eprintln!("No file specified");
//!
//! return Ok(());
//! }
//! };
//!
//! // Open a file
//! let file = File::open(filename)?;
//!
//! // Create PO parser
//! let builder = PoParser::new();
//!
//! // Parse the file
//! let pofile = builder.parse(file)?;
//!
//! // Read PO file by iterating on units
//! for unit in pofile {
//! let unit = unit?;
//!
//! // Show `msgid`
//! println!(" - {}", unit.message().get_id())
//! }
//!
//! Ok(())
//! }
//! ```
//!
//! [PO]: https://www.gnu.org/software/gettext/manual/html_node/PO-Files.html
//! [XLIFF]: https://www.oasis-open.org/committees/xliff/
//! [gettext]: https://www.gnu.org/software/gettext/
//! [tt]: http://toolkit.translatehouse.org/
extern crate locale_config;
extern crate regex;
pub use ;
use LanguageRange;
use HashMap;
/// Catalogue reader.
///
/// Defines common interface of catalogue readers. Read the units by simply iterating over the
/// reader. The other methods are for the important metadata.