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
use crate::{
Generator,
generator::flattening::{L10nDSLMaps, L10nMaps},
};
impl Generator<'_> {
/// Initializes and retrieves DSL-based localization maps
///
/// # Behavior
/// - Performs lazy initialization of DSL maps on first access
/// - Subsequent calls return cached reference
pub fn get_or_init_dsl_maps(&self) -> &L10nDSLMaps {
self
.lazy_maps
.dsl
.get_or_init(|| self.flatten_dsl_maps())
}
/// Initializes and retrieves primary localization maps
///
/// # Behavior
/// - Lazily loads core localization data on first access
/// - Caches results for subsequent requests
pub fn get_or_init_maps(&self) -> &L10nMaps {
self
.lazy_maps
.regular
.get_or_init(|| self.flatten_l10n_maps())
}
}
impl<'h> Generator<'h> {
/// Initializes and retrieves highlighted localization maps
///
/// # Behavior
/// - Lazy initialization of special highlight entries
/// - Only initializes if highlight configuration exists
pub fn get_or_init_highlight_maps(&'h self) -> Option<&'h L10nMaps> {
self
.lazy_maps
.highlight
.get_or_init(|| self.flatten_highlight_maps())
.as_ref()
}
/// Provides merged view of localization data
///
/// > Merges [Self::get_or_init_maps()] & [Self::get_or_init_highlight_maps()]
pub fn get_or_init_merged_maps(&'h self) -> &'h L10nMaps {
if self.get_highlight().is_none() {
return self.get_or_init_maps();
}
self
.lazy_maps
.merged
.get_or_init(|| self.merge_l10n_and_highlight_maps())
}
}