forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#104047 - crlf0710:icu_based_list_formatting…
…, r=davidtwco Diagnostics `icu4x` based list formatting. This adds a new kind of `DiagnosticArg` and add the ability to convert it to a `FluentValue::Custom`. When emitting fluent output, it makes use of `ListFormatter` from `icu4x` project to convert it to localized version of list following the fluent locale, as a kind of eager translation. Tested locally with locales like `en`, `ja`, etc, and they work fine. <del>Though neither `zh-CN` nor `zh-Hans` works correctly, it seems they fallback to `und` locale somehow, emitting only comma-based list. I believe this is an internal issue of `icu4x` itself.</del>(Works fine after rust-lang#104047 (comment)) Would love to hear what others think. r? `@davidtwco` cc `@Manishearth`
- Loading branch information
Showing
19 changed files
with
2,644 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[package] | ||
name = "rustc_baked_icu_data" | ||
version = "0.0.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
icu_list = "1.0.0" | ||
icu_locid = "1.0.0" | ||
icu_provider = "1.0.1" | ||
icu_provider_adapters = "1.0.0" | ||
litemap = "0.6.0" | ||
zerovec = "0.9.0" | ||
|
||
[features] | ||
rustc_use_parallel_compiler = ['icu_provider/sync'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// @generated | ||
impl AnyProvider for BakedDataProvider { | ||
fn load_any(&self, key: DataKey, req: DataRequest) -> Result<AnyResponse, DataError> { | ||
const ANDLISTV1MARKER: ::icu_provider::DataKeyHash = | ||
::icu_list::provider::AndListV1Marker::KEY.hashed(); | ||
const COLLATIONFALLBACKSUPPLEMENTV1MARKER: ::icu_provider::DataKeyHash = | ||
::icu_provider_adapters::fallback::provider::CollationFallbackSupplementV1Marker::KEY | ||
.hashed(); | ||
const LOCALEFALLBACKLIKELYSUBTAGSV1MARKER: ::icu_provider::DataKeyHash = | ||
::icu_provider_adapters::fallback::provider::LocaleFallbackLikelySubtagsV1Marker::KEY | ||
.hashed(); | ||
const LOCALEFALLBACKPARENTSV1MARKER: ::icu_provider::DataKeyHash = | ||
::icu_provider_adapters::fallback::provider::LocaleFallbackParentsV1Marker::KEY | ||
.hashed(); | ||
#[allow(clippy::match_single_binding)] | ||
match key.hashed() { | ||
ANDLISTV1MARKER => list::and_v1::DATA | ||
.get_by(|k| req.locale.strict_cmp(k.as_bytes()).reverse()) | ||
.copied() | ||
.map(AnyPayload::from_static_ref) | ||
.ok_or(DataErrorKind::MissingLocale), | ||
COLLATIONFALLBACKSUPPLEMENTV1MARKER => fallback::supplement::co_v1::DATA | ||
.get_by(|k| req.locale.strict_cmp(k.as_bytes()).reverse()) | ||
.copied() | ||
.map(AnyPayload::from_static_ref) | ||
.ok_or(DataErrorKind::MissingLocale), | ||
LOCALEFALLBACKLIKELYSUBTAGSV1MARKER => fallback::likelysubtags_v1::DATA | ||
.get_by(|k| req.locale.strict_cmp(k.as_bytes()).reverse()) | ||
.copied() | ||
.map(AnyPayload::from_static_ref) | ||
.ok_or(DataErrorKind::MissingLocale), | ||
LOCALEFALLBACKPARENTSV1MARKER => fallback::parents_v1::DATA | ||
.get_by(|k| req.locale.strict_cmp(k.as_bytes()).reverse()) | ||
.copied() | ||
.map(AnyPayload::from_static_ref) | ||
.ok_or(DataErrorKind::MissingLocale), | ||
_ => Err(DataErrorKind::MissingDataKey), | ||
} | ||
.map_err(|e| e.with_req(key, req)) | ||
.map(|payload| AnyResponse { payload: Some(payload), metadata: Default::default() }) | ||
} | ||
} |
Oops, something went wrong.