-
Notifications
You must be signed in to change notification settings - Fork 2
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
Function on Intl vs method on Intl.Locale #4
Comments
See also tc39/ecma402#31 . It proposes Intl.DisplayName. |
This is potentially a separate API. We implemented both:
I'm happy to revisit and unify, but I believe that the reason we kept locale in particular as a separate API is that it does pattern operation on language/region pair. |
The reason I want for of what Daniel describes as a second variant is because all our usecases were lists. It almost never happened that a user needs to retrieve a display name of 2 locales. In some cases its one, but in almost all cases its a high number of locales - usually for a language/region/locale selection list/menu etc. |
@zbraniecki please could you give examples for standalone language and standalone region? |
@littledan let's also compare the space complexity of each proposal. It seems like individual functions such as |
@rxaviers Do you mean this as a vote in favor of the constructor-based approach? |
Sure, let me clarify. Not a vote yet because I don't know if there are real implications... I am wondering what's the cost in terms of storage for the different proposals. I guess both constructor-based approaches (i.e., the Locale method and factory object) would need to carry the complete set of data when initialized, because it doesn't know beforehand which "subfeatures" user would use (e.g., region display names, language display names, etc). How much space does this instance cost? Is this data already available in memory or does it have to be initialized? What's the cost for multiple instances? The specific Intl function such as That being said, I'd like to hear about folks who have already implemented this and know the details. :) |
I'd be surprised if the instances had nontrivial size. I thought they would just be views onto whatever data exists in a data file and might be loaded into memory on demand, or all at once at startup (not sure how ICU loads this data exactly). |
No heap allocation. Icu data is usually memory-mapped. |
Ok thanks for clarifying... |
sorry. made some mistake in the UI and accidentally close it. |
I am in favor of the "factory object" approach |
Hi all- I am taking over the champion of this proposal now. Somehow, as a novice of github I messed up the transfer process and use a different process that won't carry all the fired issues to https://github.com/tc39/proposal-intl-displaynames. Could you refile your issue in https://github.com/tc39/proposal-intl-displaynames/issues ? Check my two proposed changes on https://github.com/tc39/proposal-intl-displaynames/pulls first. I think that address the issue you have here. I would like to ask to abandon this old one but move all discussion to https://github.com/tc39/proposal-intl-displaynames/issues instead. |
Please either close this issue or refile this and other issues in that other repo so everything can be tracked together. I think this one can be closed, right? We have sort of settled on the factory approach. |
@nciric originally suggested this feature as a method on
Intl.Locale
, rather than a function propertyIntl
. Personally, I was originally thinking that we would eventually go with this as a method on locales. There's a third possibility, of making a display name factory, analogous to other Intl formatters. Let's discuss the pros and cons of each path here:In favor of a Locale method
In favor of an Intl function
In favor of a factory object
resolvedOptions()
After writing all that out, I'm leaning slightly towards the last one, but my main intention in writing this up was so we could all think this through. Do you see any more pros or cons for particular options?
The text was updated successfully, but these errors were encountered: