Skip to main content

embedded_i18n/
guide.rs

1//! User guide for `embedded-i18n`, organized in four parts:
2//!
3//! - [tutorials]: learn by building a translated program, step by step;
4//! - [how_to]: recipes for specific tasks;
5//! - [reference](mod@reference): the macros, options, file formats and errors, exhaustively;
6//! - [explanation]: how the crate works and why it is designed this way.
7
8/// Tutorials: learn by building a translated program, step by step.
9pub mod tutorials {
10    /// From an empty project to a program translated into two languages, without allocator.
11    ///
12    #[doc = include_str!("../docs/rustdoc-links.md")]
13    #[doc = include_str!("../docs/tutorials/getting_started.md")]
14    pub mod getting_started {}
15}
16
17/// How-to guides: recipes for specific tasks.
18pub mod how_to {
19    /// Embed several locales and select one at runtime.
20    ///
21    #[doc = include_str!("../docs/rustdoc-links.md")]
22    #[doc = include_str!("../docs/how_to/switch_language_at_runtime.md")]
23    pub mod switch_language_at_runtime {}
24
25    /// Translate each call into a given locale, without a global current locale.
26    ///
27    #[doc = include_str!("../docs/rustdoc-links.md")]
28    #[doc = include_str!("../docs/how_to/localize_per_request.md")]
29    pub mod localize_per_request {}
30
31    /// Build the same code once per language, locally and in CI.
32    ///
33    #[doc = include_str!("../docs/rustdoc-links.md")]
34    #[doc = include_str!("../docs/how_to/build_one_firmware_per_language.md")]
35    pub mod build_one_firmware_per_language {}
36
37    /// Read GNU gettext PO and MO, YAML, TOML or Fluent files.
38    ///
39    #[doc = include_str!("../docs/rustdoc-links.md")]
40    #[doc = include_str!("../docs/how_to/use_gettext_po_files.md")]
41    pub mod use_gettext_po_files {}
42
43    /// Fail the build on untranslated strings with strict mode.
44    ///
45    #[doc = include_str!("../docs/rustdoc-links.md")]
46    #[doc = include_str!("../docs/how_to/ship_complete_translations.md")]
47    pub mod ship_complete_translations {}
48
49    /// Test layouts and fonts with the `pseudo` locale before translating.
50    ///
51    #[doc = include_str!("../docs/rustdoc-links.md")]
52    #[doc = include_str!("../docs/how_to/pseudo_localize.md")]
53    pub mod pseudo_localize {}
54
55    /// Mirror layouts and isolate placeholders for right-to-left languages.
56    ///
57    #[doc = include_str!("../docs/rustdoc-links.md")]
58    #[doc = include_str!("../docs/how_to/support_right_to_left_languages.md")]
59    pub mod support_right_to_left_languages {}
60
61    /// Format localized dates and times without `libc` or allocation.
62    ///
63    #[doc = include_str!("../docs/rustdoc-links.md")]
64    #[doc = include_str!("../docs/how_to/format_dates_and_times.md")]
65    pub mod format_dates_and_times {}
66
67    /// Get the Unicode ranges of a language to subset fonts.
68    ///
69    #[doc = include_str!("../docs/rustdoc-links.md")]
70    #[doc = include_str!("../docs/how_to/subset_fonts.md")]
71    pub mod subset_fonts {}
72
73    /// Move a crate from rust-i18n, item by item.
74    ///
75    #[doc = include_str!("../docs/rustdoc-links.md")]
76    #[doc = include_str!("../docs/how_to/migrate_from_rust_i18n.md")]
77    pub mod migrate_from_rust_i18n {}
78
79    /// Upgrade a crate from `embedded-i18n` 0.1, item by item.
80    ///
81    #[doc = include_str!("../docs/rustdoc-links.md")]
82    #[doc = include_str!("../docs/how_to/migrate_from_0_1.md")]
83    pub mod migrate_from_0_1 {}
84}
85
86/// Reference: the macros, options, file formats and errors, exhaustively.
87pub mod reference {
88    /// The `t!` macro: grammar, options, result types, placeholders and compile errors.
89    ///
90    #[doc = include_str!("../docs/rustdoc-links.md")]
91    #[doc = include_str!("../docs/reference/t_macro.md")]
92    pub mod t_macro {}
93
94    /// The `i18n!` arguments, `[package.metadata.i18n]` keys, environment overrides and errors.
95    ///
96    #[doc = include_str!("../docs/rustdoc-links.md")]
97    #[doc = include_str!("../docs/reference/configuration.md")]
98    pub mod configuration {}
99
100    /// Locale file formats, key layout, `backend-*` features and errors.
101    ///
102    #[doc = include_str!("../docs/rustdoc-links.md")]
103    #[doc = include_str!("../docs/reference/locale_files.md")]
104    pub mod locale_files {}
105
106    /// CLDR plural categories, built-in rules and gettext `Plural-Forms`.
107    ///
108    #[doc = include_str!("../docs/rustdoc-links.md")]
109    #[doc = include_str!("../docs/reference/plural_rules.md")]
110    pub mod plural_rules {}
111
112    /// `set_locale`, `Locale`, `locale!`, `available_locales!`, `system_locale` and `is_right_to_left`.
113    ///
114    #[doc = include_str!("../docs/rustdoc-links.md")]
115    #[doc = include_str!("../docs/reference/runtime_api.md")]
116    pub mod runtime_api {}
117
118    /// `DateTimeFormatter`, its tokens and the supported languages.
119    ///
120    #[doc = include_str!("../docs/rustdoc-links.md")]
121    #[doc = include_str!("../docs/reference/date_time.md")]
122    pub mod date_time {}
123
124    /// The Unicode ranges of each language and the range helpers.
125    ///
126    #[doc = include_str!("../docs/rustdoc-links.md")]
127    #[doc = include_str!("../docs/reference/unicode_ranges.md")]
128    pub mod unicode_ranges {}
129
130    /// Cargo features, what needs an allocator, and the supported targets.
131    ///
132    #[doc = include_str!("../docs/rustdoc-links.md")]
133    #[doc = include_str!("../docs/reference/features_and_no_std.md")]
134    pub mod features_and_no_std {}
135}
136
137/// Explanation: how the crate works and why it is designed this way.
138pub mod explanation {
139    /// What the macros generate, why `i18n!` comes first, and the ROM and RAM cost.
140    ///
141    #[doc = include_str!("../docs/rustdoc-links.md")]
142    #[doc = include_str!("../docs/explanation/how_it_works.md")]
143    pub mod how_it_works {}
144
145    /// The packed locale identifier, per-crate resolution and their limits.
146    ///
147    #[doc = include_str!("../docs/rustdoc-links.md")]
148    #[doc = include_str!("../docs/explanation/runtime_locale_model.md")]
149    pub mod runtime_locale_model {}
150
151    /// Why compile errors, `Display` values and one embedded locale by default.
152    ///
153    #[doc = include_str!("../docs/rustdoc-links.md")]
154    #[doc = include_str!("../docs/explanation/design_choices.md")]
155    pub mod design_choices {}
156
157    /// How `embedded-i18n` compares with rust-i18n, Fluent and gettext.
158    ///
159    #[doc = include_str!("../docs/rustdoc-links.md")]
160    #[doc = include_str!("../docs/explanation/comparison.md")]
161    pub mod comparison {}
162}