Skip to content
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

Automatic bundling of required cldr data with support for lazily loading additional cldr data #655

Closed
agubler opened this issue Jan 24, 2020 · 2 comments
Labels
area: i18n Internationalisation discussion The issue is up for discussion enhancement New feature or request

Comments

@agubler
Copy link
Member

agubler commented Jan 24, 2020

Goals:

Reduce the configuration and setup required for Internationalising a Dojo application, making i18n a true first class citizen. Continue to leverage Globalize/CLDR for i18n and specifically use Globalize/CLDR exclusively to resolve bundle messages and ICU formatting. To intelligently include required CLDR data based on the locale configuration specified in the application's .dojorc and whether the application requires it. Meaning that if an application does not use any formatters that none of the locale specific cldr data will be loaded.

As a side effect to more intelligent/automatic bundling of cldr-data based on the application's needs we might be able to reduce the overall bundle size at the same time.

Challenges:

  • i18n is a stand-alone module that maintains mutable state outside of the reactive Dojo architecture
  • i18n implements it’s own resolution system outside of the CLDR system
  • i18n requires users to know what cldr data is required and for it to be defined in the users .dojorc
  • The cldr data is all included in the application bundle regardless of the .dojorc config or application needs
  • There is no fallback when applications attempt to use an unsupported locale.

Proposal:

  • Adapt i18n to work reactively with the Dojo framework
  • Resolve cldr data automatically based on the locales defined in the .dojorc
  • Resolve message bundles using the built in CLDR locale resolution with bundle fallbacks
  • Bundle cldr data locale so that it can lazily loaded when required
  • Falling back to computed locale for unknown locales (loading full cldr)

Areas Affected

  • New loader and plugin for i18n/cldr data, to intelligently bundle the cldr-data and provide globals
  • Changes to core i18n and the i18n middleware/mixins to lazily load the required cldr-data

Future Considerations

In the future we might be able to make even more gains on bundle size and ergonomics by compiling the globalize bundles and formatting usages at build time, something that @mwistrand has been looking into independently of this proposal.

@agubler agubler added enhancement New feature or request discussion The issue is up for discussion area: i18n Internationalisation labels Jan 24, 2020
@agubler
Copy link
Member Author

agubler commented Jan 24, 2020

A comparison based on a standard i18n template that utilises i18n message bundles (with ICU) and the globalize unit formatter

Existing I18n System

App Url: https://dist-25sikgp60.now.sh

Bundles

  • bootstrap: 3.22kb gz
  • main 72.36kb gz

Total: 75.58kb

Note: Required cldr-data needs to be specified in the applications .dojorc

Proposed I18n System

App Url: https://dist-m7i1e9ww2.now.sh/

Bundles

  • bootstrap: 15.76kb gz
  • main: 16.47kb gz
  • supplemental: 4.09kb gz
  • en-common: 1.18kb gz
  • en-unit: 6.68kb gz

Total: 44.18kb

Note: Required cldr-data is automatically detected and bundled without .dojorc configuration

@agubler
Copy link
Member Author

agubler commented Apr 17, 2020

Landed

@agubler agubler closed this as completed Apr 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: i18n Internationalisation discussion The issue is up for discussion enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant