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
// cargo +nightly rustdoc --all-features -- --cfg __glossa_doc --document-private-items ; open ../target/doc/glossa/index.html
//! # Glossa
//!
//! Glossa is a language localisation library.
//!
//! ## Features
//!
//! - log: Enables logging of messages and errors.
//! - fluent: Used to manage localised resources at runtime.
//! - ahash: When enabled, it uses [ahash::HashMap](::ahash) by default, not [std::collections::HashMap](::std::collections::HashMap).
//!
//! ## Functionality
//!
//! It can be divided into two categories.
//!
//! - Const map: Load localisation data efficiently through constant data.
//! - Description: Convert configuration files into constant (`const fn`) Rust code at compile time and read constant data at runtime.
//! - Pros: Efficient
//! - Cons:
//! - Requires `codegen`, which may result in some redundant code after expansion.
//! - Currently only supports simple key-value (K-V) pairs.
//! - Flunt
//! - Description: Manage Fluent resources at runtime.
//! - Pros: Fluent syntax may be more suitable for localisation.
//! - Cons: Requires more resources than `const map`.
//!
//! The former is just the simple K-V pair that uses some const maps from phf to store data. Because it's simple, it's efficient.
//!
//! The two types of functionalities are independent of each other.
//!
//! There are some functions that need to be used with `glossa-codegen`, which will not be described in detail here.
//! If you want to find out more, go to the git repository for this project.
//!
//! ## Example
//!
//! In fact, you should use your own localisation resources rather than glossa's built-in `locales()`.
//!
//! It displays different content for different languages. If no relevant text is found, then it will automatically use the fallback chain.
//!
//! ```rust
//! use glossa::{locales, GetText};
//! let msg = locales().get_or_default("error", "text-not-found");
//! println!("{msg}");
//! let hello = locales()
//! .get("test", "👋🌐")
//! .expect("No localised text found. (map: test, key: 👋🌐)");
//! println!("{hello}");
//! ```
//!
/// The default error type is `GlossaError<'map>`
pub type Result<'map, T> = Result;
pub use LangResource as LangRes;
/// Get text from localised resources.
pub use GetText;
/// Load the localised resources of the HashMap.
pub use MapLoader;
/// Language Identifier
pub use LangID;
/// Contains the FallbackChain Trait implementation
pub use locales;
// Whether or not the log feature is enabled, log_macros is used
// If there is no `log`, the macro will be called without doing anything.