How to do locale fallback lookup? #3955
-
I think that when I ask, for instance, for a collator given a locale, and that specific locale does not exist, it cannot find a collator. Instead I'd like it to fall back on another locale if possible. I also found this document: which seems to have inspired this code: https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/index.html I want to try using this, but I don't understand how to turn a Is this intentional? Is it that buffer providers don't provide enough information yet, and this is not yet in the CLDR, as hinted at here: But maybe I'm on the wrong tack altogether. I can implement "subtag stripping" (as referenced by the google doc) manually but I was hoping there was something already. So let's backtrack to the base question: how do I implement a locale fallback mechanism using icu4x? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
The constructors you need are available with the |
Beta Was this translation helpful? Give feedback.
-
I just hit merge on #3334 which adds a tutorial example for this. |
Beta Was this translation helpful? Give feedback.
-
The missing serde dependency was indeed the problem. Now I'm using a fallback provider, and an either provider too (as fallback can be turned on and off), and it all appears to work the way I expect! Thank you so much for the good work! |
Beta Was this translation helpful? Give feedback.
The constructors you need are available with the
serde
feature enabled, looks like for this crate we do not have theall-features = true
docs.rs key set for 1.2 (it's fixed in 1.3), but the functions exist. A local docs build should turn up the functions you need.