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
use *;
/// The aggregate i18n state.
///
/// Constructed once per app via `App::use_i18n()`, threaded
/// through any code that needs to render translated text.
/// Cheap to `Clone` (the internal signal is
/// `Copy`-by-pointer).
///
/// # Storage
///
/// Messages are stored in a `Signal<HashMap<String,
/// HashMap<String, String>>>` keyed by `locale → (key →
/// message)`. The map is intentionally two-level: it
/// matches how translation files are typically organized
/// (`en.json` is one flat key/value map, `zh-CN.json` is
/// another, etc.) and it lets `add_messages(locale,
/// &[(k, v), ...])` build the inner map by direct
/// insertion without the user having to allocate one
/// `HashMap` per locale.
/// `I18n` is `Copy` because every field is a `Signal`, which is
/// already `Copy` — the registry hands out cheap `usize`
/// addresses for any `T: Clone + PartialEq + 'static`.