New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a lazy cache for Intl objects on MessageContext #32
Comments
Ehh, this ends up being a very non trivial task. I spent way too much time today on #rust trying to understand the limitations. It boils down to - it's not easy/possible to have a single cache for different types. If all our formatters had the same set of methods, we could do this with It is possible to use an enum here, in a Unfortunately, that requires us to change the mutability of @stasm - would you be interested in taking a look at this? Maybe you'll come up with some better model for this problem, because I feel like I'm out of ideas :( |
What needs to be cached, exactly? |
nothing yet for we don't have any intl formatters. It's likely going to be delayed till later. We're about to switch fluent to use https://github.com/unclenachoduh/pluralrules which will be the first intl formatter and it will not require any caching for now. |
but once we get intl date time formatting and number formatting we'll likely want to cache the instantiated structures. |
@mmstick with @unclenachoduh landing of the Every comparison that involves a Instead, we should do what we do in JS: https://github.com/projectfluent/fluent.js/blob/master/fluent/src/context.js#L212-L222 There are subtle differences - JS uses an Options bag, we just pass one argument, JS does language negotiation inside the constructor, we do it externally, but it boils down to the same. We want to do it once, and for the given The trick is that in the perfect world, we'd like to make the mechanism flexible enough to handle some sort of Wanna take a stab at it? |
I was able to fix it trivially for now in 7b0cd65 |
Now that we have a proper
PluralRules
object, we should cache it onMessageContext
.The text was updated successfully, but these errors were encountered: