icu4x icon indicating copy to clipboard operation
icu4x copied to clipboard

Provide a mechanism to list available locales for a given data key.

Open gregtatum opened this issue 2 years ago • 3 comments

In SpiderMonkey we are asserting in debug builds that our generated locale data are consistent by checking the locales available for different components. ICU supports this through functions like udat_getAvailable. It would be nice to have generic support of this through the provider. I did a quick look through the code and didn't see existing support for it, but I might have missed it.

It seems like with the modularity of the project, finding this out would be useful, especially if using data from different sources.

gregtatum avatar Sep 23 '21 15:09 gregtatum

Action: implement iterable data provider on runtime providers.

sffc avatar Oct 21 '21 18:10 sffc

Related: #211

I think we need a way for providers to declare what set of languages they support, not at a key level as we currently have, but at the overall provider level.

pub trait LocaleProvider {
    fn iter_locales(&self) -> impl Iterator<LanguageIdentifier>;

    fn supports_locale(&self, &LanguageIdentifier) -> bool;
}

Meanwhile, IterableProvider is and should continue to be a low-level trait with one purpose, to drive the data exporter.

This model means that providers implementing this trait must support the same set of locales for all keys. I think this is an okay and perhaps beneficial constraint. ForkByKeyProvider will not be able to implement this trait, which is fine.

sffc avatar Feb 17 '22 22:02 sffc

Mostly a duplicate of #58, which is marked as 1.x

sffc avatar Jul 25 '22 23:07 sffc