Create `fluent_embed_runtime` crate
Dependencies
- [2]
QFPQZR4KRefactor `fluent_embed` - [3]
O77KA6C4Create `fluent_embed` crate - [4]
VZYZRAO4Move `output-macros` crate into workspace - [5]
BANMRGROSwitch `wax` to temporary fork - [6]
V5S5K33AAdd basic error handling for invalid paths in proc_macro attribute - [7]
SHNZZSZGCreate `cli_macros` shim crate - [8]
XGNME3WRMove `Group::derive_enum` to new `crate::parse_macro` module - [9]
WBI5HFOBAdd simple wrapper for `libc::settext()` to query system locale - [10]
VNSHGQYNSupport using glob paths in `localize` macro - [11]
F5LG7WENEmit compilation errors from Fluent source code - [12]
NO3PDO7PRefactor `fluent_embed` to support structs - [13]
4MRF5E76Generate simple locale matching code in `localize()` - [14]
YNEOCYMGCreate `locale-select` crate - [15]
P6FW2GGORemove unnecessary parameters in generated `localize()` function - [*]
KDUI7LHJ - [*]
5TEX4MNUSplit `fluent_embed` into `group` and `parse` modules - [*]
XEEXWJLGAdd simple end-to-end test for selectors - [*]
UKFEFT6LCreate basic `Output` proc-macro - [*]
JZXXFWQKAdd tests for `locale_select` backends on unix
Change contents
- file addition: fluent_embed_runtime[17.1]
- file addition: src[0.32]
- file addition: lib.rs[0.49]
use icu_provider::DataLocale;// Public re-exports of dependencies required at runtime, so macro-generated code// can find all the dependencies it expects as long as this crate existspub use icu_locid::{self, langid, LanguageIdentifier};pub use icu_plurals::{self, PluralRuleType, PluralRules};pub use locale_select;pub trait Localize {const CANONICAL_LOCALE: LanguageIdentifier;fn localize(&self) -> String;}/// Select which locale to use, falling back to the canonical locale if nothing matchespub fn select_locale(available_locales: &[LanguageIdentifier],canonical_locale: &LanguageIdentifier,) -> LanguageIdentifier {locale_select::match_locales(available_locales, canonical_locale)}pub fn plural_rules(locale: &LanguageIdentifier,rule_type: PluralRuleType,) -> Result<PluralRules, icu_plurals::Error> {let data_locale = DataLocale::from(locale);PluralRules::try_new(&data_locale, rule_type)} - file addition: Cargo.toml[0.32]
[package]name = "fluent_embed_runtime"version = "0.1.0"edition = "2021"[lints]workspace = true[dependencies]icu_locid = "1.4.0"icu_plurals = "1.4.0"icu_provider = "1.4.0"locale_select = { path = "../locale_select" } - edit in fluent_embed/src/lib.rs at line 80
let canonical_locale = group.canonical_locale().id.clone().to_string(); - edit in fluent_embed/src/lib.rs at line 91
- replacement in fluent_embed/src/lib.rs at line 93
impl #ident {// TODO: most of this shouldn't be generated on every callimpl ::fluent_embed_runtime::Localize for #ident {const CANONICAL_LOCALE: ::fluent_embed_runtime::icu_locid::LanguageIdentifier =::fluent_embed_runtime::icu_locid::langid!(#canonical_locale); - replacement in fluent_embed/src/fluent/ast.rs at line 27
parse_quote!(::icu_plurals::PluralCategory::#ident)parse_quote!(::fluent_embed_runtime::icu_plurals::PluralCategory::#ident) - edit in fluent_embed/src/derive.rs at line 26
let canonical_locale = group.canonical_locale().id.to_string(); - replacement in fluent_embed/src/derive.rs at line 39
// Find the appropriate locale to uselet additional_locales = [#(::icu_locid::langid!(#additional_locales)),*];let canonical_locale = ::icu_locid::langid!(#canonical_locale);let locale = ::locale_select::match_locales(&additional_locales, &canonical_locale);// Create a list of available locales to choose fromlet available_locales = [// The canonical locale will always be availableSelf::CANONICAL_LOCALE,// Any additional locales that contain this message#(::fluent_embed_runtime::langid!(#additional_locales)),*];let locale = ::fluent_embed_runtime::select_locale(&available_locales, &Self::CANONICAL_LOCALE); - replacement in fluent_embed/src/derive.rs at line 49
let plural_rule_type = ::icu_plurals::PluralRuleType::Cardinal;let plural_rules = ::icu_plurals::PluralRules::try_new(&locale.clone().into(), plural_rule_type).unwrap();// TODO: only generate this when needed in messageconst plural_rule_type: ::fluent_embed_runtime::PluralRuleType =::fluent_embed_runtime::PluralRuleType::Cardinal;let plural_rules = ::fluent_embed_runtime::plural_rules(&locale, plural_rule_type).unwrap(); - edit in fluent_embed/src/derive.rs at line 54
// Handle any additional locales - edit in fluent_embed/src/derive.rs at line 56
// Fall back to the canonical locale, if no other valid locale was matched - edit in cli_macros/tests/selectors.rs at line 4
use fluent_embed_runtime::Localize; - replacement in cli_macros/Cargo.toml at line 22
icu_locid = "1.4.0"icu_plurals = "1.4.0"locale_select = { path = "../locale_select" }[3.991]fluent_embed_runtime = { path = "../fluent_embed_runtime" } - replacement in Cargo.toml at line 2
members = ["fluent_embed", "output-macros", "cli_macros", "locale_select"]members = ["fluent_embed", "output-macros", "cli_macros", "locale_select", "fluent_embed_runtime"] - replacement in Cargo.lock at line 82
"icu_locid","icu_plurals","locale_select","fluent_embed_runtime", - edit in Cargo.lock at line 182[3.1960][21.378]
][[package]]name = "fluent_embed_runtime"version = "0.1.0"dependencies = ["icu_locid","icu_plurals","icu_provider","locale_select", - replacement in Cargo.lock at line 637
version = "1.13.1"version = "1.13.2" - replacement in Cargo.lock at line 639
checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7"checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"