icu4x
icu4x copied to clipboard
Provide a mechanism to list available locales for a given data key.
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.
Action: implement iterable data provider on runtime providers.
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.
Mostly a duplicate of #58, which is marked as 1.x