Skip to content

Commit

Permalink
rename locale_prefs to locale_preferences (#5990)
Browse files Browse the repository at this point in the history
Fixes #5786
  • Loading branch information
Manishearth authored Jan 14, 2025
1 parent cc68692 commit 2d305ff
Show file tree
Hide file tree
Showing 23 changed files with 129 additions and 79 deletions.
2 changes: 1 addition & 1 deletion components/calendar/src/any_calendar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,7 @@ impl AnyCalendarKind {
if let Some(kind) = Self::get_for_prefs(prefs) {
kind
} else {
let lang = prefs.locale_prefs.language;
let lang = prefs.locale_preferences.language;
if lang == language!("th") {
Self::Buddhist
} else if lang == language!("sa") {
Expand Down
3 changes: 2 additions & 1 deletion components/calendar/src/week_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ impl WeekCalculator {
where
P: DataProvider<crate::provider::WeekDataV2Marker> + ?Sized,
{
let locale = DataLocale::from_preferences_locale::<WeekDataV2Marker>(prefs.locale_prefs);
let locale =
DataLocale::from_preferences_locale::<WeekDataV2Marker>(prefs.locale_preferences);
provider
.load(DataRequest {
id: DataIdentifierBorrowed::for_locale(&locale),
Expand Down
5 changes: 3 additions & 2 deletions components/collator/src/comparison.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ impl LocaleSpecificDataHolder {
.map(|c| DataMarkerAttributes::from_str_or_panic(c.as_str()))
.unwrap_or_default();

let data_locale =
DataLocale::from_preferences_locale::<CollationTailoringV1Marker>(prefs.locale_prefs);
let data_locale = DataLocale::from_preferences_locale::<CollationTailoringV1Marker>(
prefs.locale_preferences,
);
let id = DataIdentifierCow::from_borrowed_and_owned(marker_attributes, data_locale.clone());

let req = DataRequest {
Expand Down
6 changes: 3 additions & 3 deletions components/collator/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1451,7 +1451,7 @@ fn test_nb_nn_no() {
DataRequest {
id: DataIdentifierCow::from_locale(DataLocale::from_preferences_locale::<
CollationTailoringV1Marker,
>(prefs.locale_prefs))
>(prefs.locale_preferences))
.as_borrowed(),
..Default::default()
}
Expand All @@ -1474,7 +1474,7 @@ fn test_nb_nn_no() {
DataRequest {
id: DataIdentifierCow::from_locale(DataLocale::from_preferences_locale::<
CollationTailoringV1Marker,
>(prefs.locale_prefs))
>(prefs.locale_preferences))
.as_borrowed(),
..Default::default()
}
Expand All @@ -1497,7 +1497,7 @@ fn test_nb_nn_no() {
DataRequest {
id: DataIdentifierCow::from_locale(DataLocale::from_preferences_locale::<
CollationTailoringV1Marker,
>(prefs.locale_prefs))
>(prefs.locale_preferences))
.as_borrowed(),
..Default::default()
}
Expand Down
2 changes: 1 addition & 1 deletion components/datetime/src/neo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ define_preferences!(
/// let prefs1: DateTimeFormatterPreferences = Locale::try_from_str("fr-u-ca-buddhist-hc-h12").unwrap().into();
///
/// let mut prefs2 = DateTimeFormatterPreferences::default();
/// prefs2.locale_prefs.language = Language::try_from_str("fr").unwrap();
/// prefs2.locale_preferences.language = Language::try_from_str("fr").unwrap();
/// prefs2.hour_cycle = Some(HourCycle::H12);
/// prefs2.calendar_algorithm = Some(CalendarAlgorithm::Buddhist);
///
Expand Down
40 changes: 30 additions & 10 deletions components/datetime/src/pattern/names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1789,7 +1789,9 @@ impl<FSet: DateTimeNamesMarker> RawDateTimeNames<FSet> {
P: BoundDataProvider<YearNamesV1Marker> + ?Sized,
{
let attributes = length.to_attributes();
let locale = provider.bound_marker().make_locale(prefs.locale_prefs);
let locale = provider
.bound_marker()
.make_locale(prefs.locale_preferences);
let req = DataRequest {
id: DataIdentifierBorrowed::for_marker_attributes_and_locale(attributes, &locale),
..Default::default()
Expand All @@ -1812,7 +1814,9 @@ impl<FSet: DateTimeNamesMarker> RawDateTimeNames<FSet> {
P: BoundDataProvider<MonthNamesV1Marker> + ?Sized,
{
let attributes = length.to_attributes();
let locale = provider.bound_marker().make_locale(prefs.locale_prefs);
let locale = provider
.bound_marker()
.make_locale(prefs.locale_preferences);
let req = DataRequest {
id: DataIdentifierBorrowed::for_marker_attributes_and_locale(attributes, &locale),
..Default::default()
Expand All @@ -1835,7 +1839,9 @@ impl<FSet: DateTimeNamesMarker> RawDateTimeNames<FSet> {
P: BoundDataProvider<DayPeriodNamesV1Marker> + ?Sized,
{
let attributes = length.to_attributes();
let locale = provider.bound_marker().make_locale(prefs.locale_prefs);
let locale = provider
.bound_marker()
.make_locale(prefs.locale_preferences);
let req = DataRequest {
id: DataIdentifierBorrowed::for_marker_attributes_and_locale(attributes, &locale),
..Default::default()
Expand All @@ -1858,7 +1864,9 @@ impl<FSet: DateTimeNamesMarker> RawDateTimeNames<FSet> {
P: BoundDataProvider<WeekdayNamesV1Marker> + ?Sized,
{
let attributes = length.to_attributes();
let locale = provider.bound_marker().make_locale(prefs.locale_prefs);
let locale = provider
.bound_marker()
.make_locale(prefs.locale_preferences);
let req = DataRequest {
id: DataIdentifierBorrowed::for_marker_attributes_and_locale(attributes, &locale),
..Default::default()
Expand All @@ -1878,7 +1886,9 @@ impl<FSet: DateTimeNamesMarker> RawDateTimeNames<FSet> {
where
P: BoundDataProvider<tz::EssentialsV1Marker> + ?Sized,
{
let locale = provider.bound_marker().make_locale(prefs.locale_prefs);
let locale = provider
.bound_marker()
.make_locale(prefs.locale_preferences);
let error_field = ErrorField(fields::Field {
symbol: FieldSymbol::TimeZone(fields::TimeZone::LocalizedOffset),
length: FieldLength::Four,
Expand All @@ -1903,7 +1913,9 @@ impl<FSet: DateTimeNamesMarker> RawDateTimeNames<FSet> {
where
P: BoundDataProvider<tz::LocationsV1Marker> + ?Sized,
{
let locale = provider.bound_marker().make_locale(prefs.locale_prefs);
let locale = provider
.bound_marker()
.make_locale(prefs.locale_preferences);
let error_field = ErrorField(fields::Field {
symbol: FieldSymbol::TimeZone(fields::TimeZone::Location),
length: FieldLength::Four,
Expand Down Expand Up @@ -1946,7 +1958,9 @@ impl<FSet: DateTimeNamesMarker> RawDateTimeNames<FSet> {
mz_period_provider: &(impl BoundDataProvider<tz::MzPeriodV1Marker> + ?Sized),
prefs: DateTimeFormatterPreferences,
) -> Result<(), PatternLoadError> {
let locale = provider.bound_marker().make_locale(prefs.locale_prefs);
let locale = provider
.bound_marker()
.make_locale(prefs.locale_preferences);
let error_field = ErrorField(fields::Field {
symbol: FieldSymbol::TimeZone(fields::TimeZone::GenericNonLocation),
length: FieldLength::Four,
Expand All @@ -1970,7 +1984,9 @@ impl<FSet: DateTimeNamesMarker> RawDateTimeNames<FSet> {
mz_period_provider: &(impl BoundDataProvider<tz::MzPeriodV1Marker> + ?Sized),
prefs: DateTimeFormatterPreferences,
) -> Result<(), PatternLoadError> {
let locale = provider.bound_marker().make_locale(prefs.locale_prefs);
let locale = provider
.bound_marker()
.make_locale(prefs.locale_preferences);
let error_field = ErrorField(fields::Field {
symbol: FieldSymbol::TimeZone(fields::TimeZone::GenericNonLocation),
length: FieldLength::One,
Expand All @@ -1994,7 +2010,9 @@ impl<FSet: DateTimeNamesMarker> RawDateTimeNames<FSet> {
mz_period_provider: &(impl BoundDataProvider<tz::MzPeriodV1Marker> + ?Sized),
prefs: DateTimeFormatterPreferences,
) -> Result<(), PatternLoadError> {
let locale = provider.bound_marker().make_locale(prefs.locale_prefs);
let locale = provider
.bound_marker()
.make_locale(prefs.locale_preferences);
let error_field = ErrorField(fields::Field {
symbol: FieldSymbol::TimeZone(fields::TimeZone::SpecificNonLocation),
length: FieldLength::Four,
Expand All @@ -2018,7 +2036,9 @@ impl<FSet: DateTimeNamesMarker> RawDateTimeNames<FSet> {
mz_period_provider: &(impl BoundDataProvider<tz::MzPeriodV1Marker> + ?Sized),
prefs: DateTimeFormatterPreferences,
) -> Result<(), PatternLoadError> {
let locale = provider.bound_marker().make_locale(prefs.locale_prefs);
let locale = provider
.bound_marker()
.make_locale(prefs.locale_preferences);
let error_field = ErrorField(fields::Field {
symbol: FieldSymbol::TimeZone(fields::TimeZone::SpecificNonLocation),
length: FieldLength::One,
Expand Down
16 changes: 12 additions & 4 deletions components/datetime/src/raw/neo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ impl DatePatternSelectionData {
attributes: &DataMarkerAttributes,
options: RawOptions,
) -> Result<Self, DataError> {
let locale = provider.bound_marker().make_locale(prefs.locale_prefs);
let locale = provider
.bound_marker()
.make_locale(prefs.locale_preferences);
let payload = provider
.load_bound(DataRequest {
id: DataIdentifierBorrowed::for_marker_attributes_and_locale(attributes, &locale),
Expand Down Expand Up @@ -297,7 +299,9 @@ impl OverlapPatternSelectionData {
attributes: &DataMarkerAttributes,
options: RawOptions,
) -> Result<Self, DataError> {
let locale = provider.bound_marker().make_locale(prefs.locale_prefs);
let locale = provider
.bound_marker()
.make_locale(prefs.locale_preferences);
let prefs = RawPreferences::from_prefs(prefs);
let payload = provider
.load_bound(DataRequest {
Expand Down Expand Up @@ -364,7 +368,9 @@ impl TimePatternSelectionData {
components: TimeFieldSet,
options: RawOptions,
) -> Result<Self, DataError> {
let locale = provider.bound_marker().make_locale(prefs.locale_prefs);
let locale = provider
.bound_marker()
.make_locale(prefs.locale_preferences);
let prefs = RawPreferences::from_prefs(prefs);
// First try to load with the explicit hour cycle. If there is no explicit hour cycle,
// or if loading the explicit hour cycle fails, then load with the default hour cycle.
Expand Down Expand Up @@ -622,7 +628,9 @@ impl DateTimeZonePatternSelectionData {
options: RawOptions,
glue_type: GlueType,
) -> Result<DataPayload<GluePatternV1Marker>, DataError> {
let locale = provider.bound_marker().make_locale(prefs.locale_prefs);
let locale = provider
.bound_marker()
.make_locale(prefs.locale_preferences);
provider
.load_bound(DataRequest {
id: DataIdentifierBorrowed::for_marker_attributes_and_locale(
Expand Down
2 changes: 1 addition & 1 deletion components/decimal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ impl FixedDecimalFormatter {
options: options::FixedDecimalFormatterOptions,
) -> Result<Self, DataError> {
let locale = DataLocale::from_preferences_locale::<provider::DecimalSymbolsV2Marker>(
prefs.locale_prefs,
prefs.locale_preferences,
);
let provided_nu = prefs.numbering_system.as_ref().map(|s| s.as_str());

Expand Down
8 changes: 4 additions & 4 deletions components/experimental/src/compactdecimal/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl CompactDecimalFormatter {
options: CompactDecimalFormatterOptions,
) -> Result<Self, DataError> {
let locale = DataLocale::from_preferences_locale::<ShortCompactDecimalFormatDataV1Marker>(
prefs.locale_prefs,
prefs.locale_preferences,
);
Ok(Self {
fixed_decimal_formatter: FixedDecimalFormatter::try_new(
Expand Down Expand Up @@ -155,7 +155,7 @@ impl CompactDecimalFormatter {
+ ?Sized,
{
let locale = DataLocale::from_preferences_locale::<ShortCompactDecimalFormatDataV1Marker>(
prefs.locale_prefs,
prefs.locale_preferences,
);
Ok(Self {
fixed_decimal_formatter: FixedDecimalFormatter::try_new_unstable(
Expand Down Expand Up @@ -201,7 +201,7 @@ impl CompactDecimalFormatter {
options: CompactDecimalFormatterOptions,
) -> Result<Self, DataError> {
let locale = DataLocale::from_preferences_locale::<LongCompactDecimalFormatDataV1Marker>(
prefs.locale_prefs,
prefs.locale_preferences,
);
Ok(Self {
fixed_decimal_formatter: FixedDecimalFormatter::try_new(
Expand Down Expand Up @@ -246,7 +246,7 @@ impl CompactDecimalFormatter {
+ ?Sized,
{
let locale = DataLocale::from_preferences_locale::<LongCompactDecimalFormatDataV1Marker>(
prefs.locale_prefs,
prefs.locale_preferences,
);
Ok(Self {
fixed_decimal_formatter: FixedDecimalFormatter::try_new_unstable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ impl CompactCurrencyFormatter {
prefs: CompactCurrencyFormatterPreferences,
options: CompactCurrencyFormatterOptions,
) -> Result<Self, DataError> {
let short_locale =
DataLocale::from_preferences_locale::<ShortCurrencyCompactV1Marker>(prefs.locale_prefs);
let short_locale = DataLocale::from_preferences_locale::<ShortCurrencyCompactV1Marker>(
prefs.locale_preferences,
);

let short_currency_compact = crate::provider::Baked
.load(DataRequest {
Expand All @@ -100,8 +101,9 @@ impl CompactCurrencyFormatter {
})?
.payload;

let essential_locale =
DataLocale::from_preferences_locale::<CurrencyEssentialsV1Marker>(prefs.locale_prefs);
let essential_locale = DataLocale::from_preferences_locale::<CurrencyEssentialsV1Marker>(
prefs.locale_preferences,
);

let essential = crate::provider::Baked
.load(DataRequest {
Expand Down Expand Up @@ -138,8 +140,9 @@ impl CompactCurrencyFormatter {
+ DataProvider<icu_decimal::provider::DecimalDigitsV1Marker>
+ DataProvider<icu_plurals::provider::CardinalV1Marker>,
{
let locale =
DataLocale::from_preferences_locale::<CurrencyEssentialsV1Marker>(prefs.locale_prefs);
let locale = DataLocale::from_preferences_locale::<CurrencyEssentialsV1Marker>(
prefs.locale_preferences,
);

let compact_decimal_formatter = CompactDecimalFormatter::try_new_short_unstable(
provider,
Expand Down
10 changes: 6 additions & 4 deletions components/experimental/src/dimension/currency/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ impl CurrencyFormatter {
prefs: CurrencyFormatterPreferences,
options: super::options::CurrencyFormatterOptions,
) -> Result<Self, DataError> {
let locale =
DataLocale::from_preferences_locale::<CurrencyEssentialsV1Marker>(prefs.locale_prefs);
let locale = DataLocale::from_preferences_locale::<CurrencyEssentialsV1Marker>(
prefs.locale_preferences,
);
let fixed_decimal_formatter = FixedDecimalFormatter::try_new(
(&prefs).into(),
FixedDecimalFormatterOptions::default(),
Expand Down Expand Up @@ -113,8 +114,9 @@ impl CurrencyFormatter {
+ DataProvider<icu_decimal::provider::DecimalSymbolsV2Marker>
+ DataProvider<icu_decimal::provider::DecimalDigitsV1Marker>,
{
let locale =
DataLocale::from_preferences_locale::<CurrencyEssentialsV1Marker>(prefs.locale_prefs);
let locale = DataLocale::from_preferences_locale::<CurrencyEssentialsV1Marker>(
prefs.locale_preferences,
);
let fixed_decimal_formatter = FixedDecimalFormatter::try_new_unstable(
provider,
(&prefs).into(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl LongCompactCurrencyFormatter {
})?;

let locale = &DataLocale::from_preferences_locale::<CurrencyPatternsDataV1Marker>(
prefs.locale_prefs,
prefs.locale_preferences,
);

let extended = crate::provider::Baked
Expand Down Expand Up @@ -143,8 +143,9 @@ impl LongCompactCurrencyFormatter {
+ DataProvider<icu_plurals::provider::CardinalV1Marker>
+ DataProvider<crate::compactdecimal::provider::LongCompactDecimalFormatDataV1Marker>,
{
let locale =
DataLocale::from_preferences_locale::<CurrencyPatternsDataV1Marker>(prefs.locale_prefs);
let locale = DataLocale::from_preferences_locale::<CurrencyPatternsDataV1Marker>(
prefs.locale_preferences,
);

let marker_attributes = DataMarkerAttributes::try_from_str(currency_code.0.as_str())
.map_err(|_| {
Expand Down
10 changes: 6 additions & 4 deletions components/experimental/src/dimension/currency/long_formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ impl LongCurrencyFormatter {
prefs: CurrencyFormatterPreferences,
currency_code: &CurrencyCode,
) -> Result<Self, DataError> {
let locale =
DataLocale::from_preferences_locale::<CurrencyPatternsDataV1Marker>(prefs.locale_prefs);
let locale = DataLocale::from_preferences_locale::<CurrencyPatternsDataV1Marker>(
prefs.locale_preferences,
);
let fixed_decimal_formatter = FixedDecimalFormatter::try_new(
(&prefs).into(),
FixedDecimalFormatterOptions::default(),
Expand Down Expand Up @@ -113,8 +114,9 @@ impl LongCurrencyFormatter {
+ DataProvider<icu_decimal::provider::DecimalDigitsV1Marker>
+ DataProvider<icu_plurals::provider::CardinalV1Marker>,
{
let locale =
DataLocale::from_preferences_locale::<CurrencyPatternsDataV1Marker>(prefs.locale_prefs);
let locale = DataLocale::from_preferences_locale::<CurrencyPatternsDataV1Marker>(
prefs.locale_preferences,
);
let fixed_decimal_formatter = FixedDecimalFormatter::try_new_unstable(
provider,
(&prefs).into(),
Expand Down
10 changes: 6 additions & 4 deletions components/experimental/src/dimension/percent/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,9 @@ where
fixed_decimal_formatter: R,
options: PercentFormatterOptions,
) -> Result<Self, DataError> {
let locale =
DataLocale::from_preferences_locale::<PercentEssentialsV1Marker>(prefs.locale_prefs);
let locale = DataLocale::from_preferences_locale::<PercentEssentialsV1Marker>(
prefs.locale_preferences,
);
let essential = crate::provider::Baked
.load(DataRequest {
id: DataIdentifierBorrowed::for_locale(&locale),
Expand All @@ -177,8 +178,9 @@ where
fixed_decimal_formatter: R,
options: PercentFormatterOptions,
) -> Result<Self, DataError> {
let locale =
DataLocale::from_preferences_locale::<PercentEssentialsV1Marker>(prefs.locale_prefs);
let locale = DataLocale::from_preferences_locale::<PercentEssentialsV1Marker>(
prefs.locale_preferences,
);
let essential = provider
.load(DataRequest {
id: DataIdentifierBorrowed::for_locale(&locale),
Expand Down
Loading

0 comments on commit 2d305ff

Please sign in to comment.