-
Notifications
You must be signed in to change notification settings - Fork 78
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
Remove Globalize.js in favor of Intl
(and MessageFormat
)
#250
Comments
Could Luxon be used to help with this effort or would it be something that users could optionally use on top of this? |
@mwistrand I'm all for this 👍 a few comments:
|
@mwistrand I second that, any changes that move us closer to the native platform and dependency free are big wins for me. It would be great if we could detail the affected areas of the framework, with the work that needs to be done. Then we can work towards a POC for version 6 👍 |
@dasa Users are always free to use other libraries in their applications/custom elements, but I'd have to research such tools more to know whether it'd be good to provide custom build scenarios for them. @matt-gadd It may be possible to map globalize formatter options back to native As for pre-compiling messages, we need to be able to determine which files contain those messages. For various reasons, we went with ES modules when other libraries use JSON or some other non-ES file type for locale messages. As such, it's difficult to differentiate from message files and other files, in turn making it difficult to pre-compile messages at build time. @agubler Within the framework itself, only |
@mwistrand as I said I’d like to see what bundle size reductions we’d actually gain by pre-compiling in the first place. If it’s not absolutely significant i wouldn’t want to make a sweeping breaking change on the message bundle file format or spend the time on potentially complicated build tooling. That’s one of the reasons using modules is actually really nice currently (+ bonus points that we can lazily load bundles down to a per language per bundle level). I don’t think even if we were using json it would be any less ambiguous either (same issue, no?). |
On the legacy globalize api’s, if we can’t manage to transform them at runtime it’s even more unlikely we’ll be able to transform them statically via cli-upgrade-app, which may be fine but would likely mean a manual migration guide. |
It seems the unit formatting cannot map to existing functionality, so that would need to be manually updated. I mistakenly thought unit formatting was provided by one of the more advanced ECMA-402 proposals, but misremembered that. If we really wanted to avoid breaking changes (which I understand), we could keep globalize for the time being, log deprecation warnings to either use I've mentioned this elsewhere in the past, but it should be possible to continue treating globalize as a first-class citizen by providing build-time support as there are existing plugins that pre-compile Globalize formatters, which would be possible to use if applications called those methods directly instead of through Dojo. |
Enhancement
Dojo currently uses Globalize.js for the bulk of its internationalization/localization functionality, but at this point
Intl
is well-supported and robust enough that it can handle most use cases. For supported browsers that lackIntl
support, there are shims available (Intl
andIntl.RelativeFormat
). With that in mind, we can remove Globalize.js, use MessageFormat internally for managing ICU message formatting, and recommend the nativeIntl
for anything else.This would be a breaking change, and applications that use functions like
formatCurrency
would need to update to their native equivalents likeIntl.NumberFormat
. Perhaps@dojo/cli-upgrade-app
could help mitigate any manual updatesWith regard to the build, conditional polyfill loading should help reduce the bundle size, but it would also be possible to pre-compile any messages and therefore eliminate most of the bulk from the MessageFormat library as well. However, doing so will be difficult without a standard means of differentiating message bundles from other files. Just as Dojo uses
m.css
to distinguish CSS module files from other CSS files, perhaps a similar approach could be used for localized message files. The build would then pre-compile the messages in these files andMessageFormat
could be ignored entirely. More discussion is needed here.The text was updated successfully, but these errors were encountered: