Update I18n modules to support loading automatically bundled CLDR data#657
Conversation
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 449f5dc:
|
55135af to
e3fc460
Compare
| const localCldrLoader = cldrLoaders[userLocale]; | ||
| if (localCldrLoader && localCldrLoader !== true) { | ||
| loaderPromises.push(localCldrLoader()); | ||
| } |
There was a problem hiding this comment.
Can this be changed from localCldrLoader to localeCldrLoader since it's specific to the locale and has nothing to do with the local option?
| messages: Object.keys(bundle.messages).reduce( | ||
| (messages, key) => { | ||
| const message = globalize.cldr.get(`${MESSAGE_BUNDLE_PATH}/${bundleId}/${key}`); | ||
| messages[key] = message; | ||
| return messages; | ||
| }, | ||
| {} as any | ||
| ), |
There was a problem hiding this comment.
When called from within middleware/i18n.localize(), will this object be regenerated each time the widget is invalidated? If so, caching the result would be nice.
| root.innerHTML, | ||
| '<div><div>{"foo":""}</div><div></div><div>true</div><div>{"locale":"es"}</div><button>es</button></div>' | ||
| ); | ||
| es.resolver({ default: { foo: 'holla, {name}' } }); |
There was a problem hiding this comment.
Nit: "hello" in Spanish is "hola" ![]()
| loadData(frCurrencies); | ||
| loadData(frNumbers); | ||
| loadData(frUnits); | ||
| }); |
There was a problem hiding this comment.
Just verifying nothing throws?
There was a problem hiding this comment.
This is used to load data in for the tests, runs in both browser and node.
ed6f373 to
f28b9b0
Compare
|
@mwistrand I think I've addressed your comments |
5ab6911 to
449f5dc
Compare
Codecov Report
@@ Coverage Diff @@
## master #657 +/- ##
==========================================
- Coverage 98.06% 97.80% -0.26%
==========================================
Files 120 117 -3
Lines 6654 6570 -84
Branches 1510 1494 -16
==========================================
- Hits 6525 6426 -99
- Misses 129 144 +15
Continue to review full report at Codecov.
|
Type: feature
The following has been addressed in the PR:
prettieras per the readme code style guidelinesDescription:
Comprehensive change of i18n support in Dojo; The motivation is to enable automatic detection of CLDR data requirements with lazy loading and resolution of i18n CLDR data bundles. Ensuring that CLDR data automatically included in i18n enables Dojo to remove existing custom locale resolution logic and entirely depend on
Globalizefor locale resolution.This should be backwards compatible, unless the downstream application is importing interfaces that are no longer needed (and can be removed) or using the core i18n module directly (which shouldn't be required).
Details:
Globalizefor all message bundle resolution.cldrmodule that loads the required supplemental data (This import will automatically be elided during the Dojo build)Related to #655