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
// Copyright (c) 2026 Kirky.X
// SPDX-License-Identifier: MIT
//! ICU4X-backed internationalization formatting for rate-limit operations.
//!
//! Provides locale-aware number formatting, date formatting, plural rules,
//! and string collation via the `icu` crate (ICU4X 2.x). Useful for
//! generating locale-sensitive rate-limit messages (e.g. "1 request" vs
//! "2 requests"), formatting rate-limit counters, displaying window expiry
//! times, and sorting rate-limit rules by locale-specific collation rules.
//!
//! Enable with the `i18n` cargo feature:
//! ```toml
//! [dependencies]
//! limiteron = { version = "...", features = ["i18n"] }
//! ```
//!
//! # Example
//!
//! ```rust,ignore
//! use limiteron::i18n::LimiterI18nFormatter;
//!
//! let fmt = LimiterI18nFormatter::new("en-US")?;
//! let msg = fmt.format_rate_limit_message(5, 100, "minute")?;
//! let plural = fmt.format_count(1)?; // "One"
//! let window = fmt.format_window(2026, 7, 11)?;
//! ```
use CollatorBorrowed;
use DecimalFormatter;
use Locale;
use PluralRules;
use Error;
/// Errors returned by [`LimiterI18nFormatter`] operations.
/// Locale-aware formatter backed by ICU4X compiled data.
///
/// Construct with [`LimiterI18nFormatter::new`] using a BCP-47 locale tag
/// (e.g. `"en-US"`, `"zh-CN"`). All formatters are created eagerly so
/// that repeated formatting calls are allocation-light.