unicode-org / icu4x

Solving i18n for client-side and resource-constrained environments.
https://icu4x.unicode.org
Other
1.37k stars 175 forks source link

Allow combinatorics on provider::Baked #3935

Open sffc opened 1 year ago

sffc commented 1 year ago

Users should be able to chain provider::Baked providers to make a multi-crate AnyProvider.

@Manishearth suggested aked.add(otherprovider::Baked) making a fork provider.

robertbastian commented 1 year ago

crate::provider::Baked is an implementation detail in the unstable provider modules. Users can use compiled data by depending on the data crates and creating their own baked providers:


struct MyBakedProvider;

icu_datetime_data::impl_datetime_chinese_datelengths_v1!(MyBakedProvider);
icu_datetime_data::impl_datetime_chinese_datesymbols_v1!(MyBakedProvider);
icu_list_data::impl_and_list_v1!(MyBakedProvider);
sffc commented 1 year ago

Discuss with:

sffc commented 1 year ago

Discussion: revisit this in the context of #3947, when we remove AnyProvider. Leaving some breadcrumbs for my mental model of this and #1893:

sffc commented 1 year ago

Another use case here is if you want your language packs to contain only non-singleton keys and get the singleton keys from compiled data with the non-singleton keys from dynamically loaded data.

A few approaches here:

  1. Use with_any_provider constructors and a registry macro that forks between the singleton compiled data and the blob dynamic data
  2. Use _unstable constructors (but then we don't handle older blob data)
  3. Use a new type of constructor called _unstable_with_backwards_compatibility
  4. Use _with_buffer_provider and export the singleton keys as blobs from the data crates
  5. In 2.0 make _with_provider constructors that take an enum between BufferProvider and AnyProvider (or equivalent) and fork between the singleton static data and the blob data (and use this opportunity to reduce the number of constructors -- rather than deleting _with_any_provider we merge it in with the buffer provider constructor, which slightly increases the buffer provider constructor code size but only by the size of a ZeroFrom)
sffc commented 8 months ago

Probably doesn't block 2.0 so removing it from that milestone, but it is still important.