refactor(common): refactor i18n code to ease tree shaking#18857
refactor(common): refactor i18n code to ease tree shaking#18857vicb wants to merge 2 commits intoangular:masterfrom
Conversation
| * @experimental i18n support is experimental. | ||
| */ | ||
| export function registerLocaleData(data: any, extraData?: any) { | ||
| const localeId = toCamelCase(data[LocaleDataIndex.LocaleId]); |
There was a problem hiding this comment.
@ocombe Do we really need those toCamelCase calls ?
There was a problem hiding this comment.
No we can probably remove this
|
You can preview e9e8bfa at https://pr18857-e9e8bfa.ngbuilds.io/. |
| * @experimental i18n support is experimental. | ||
| */ | ||
| export function registerLocaleData(data: any, extraData?: any) { | ||
| const localeId = toCamelCase(data[LocaleDataIndex.LocaleId]); |
There was a problem hiding this comment.
No we can probably remove this
|
|
||
| throw new Error( | ||
| `Missing locale data for the locale "${locale}". Use "registerLocaleData" to load new data. See the "I18n guide" on angular.io to know more.`); | ||
| throw new Error(`No data registered for the locale "${locale}".`); |
There was a problem hiding this comment.
This change in the error message was asked by @StephenFluin. Since this is probably something that any dev who doesn't use en-US will see, it's important that they don't feel lost with a non-informative error message
There was a problem hiding this comment.
@StephenFluin The longer the message the higher the payload. The right solution is to have error code as in AngularJS. Until then we should restrict from using longer than needed msgs IMO.
There was a problem hiding this comment.
It's actually a good idea, we should have error codes. I'll submit the idea
| Two = 2, | ||
| Few = 3, | ||
| Many = 4, | ||
| Other = 5, |
There was a problem hiding this comment.
Zero = 0 is enough here, the other ones will be 1 to 5 since they follow 0
There was a problem hiding this comment.
enough but not explicit
There was a problem hiding this comment.
I guess it doesn't matter, typescript will add the numbers anyway
There was a problem hiding this comment.
It matters. It is a signal not to add a value in the middle.
|
Note: the Travis failure is unrelated to this PR |
|
will be merged via #18907 |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
The former structure was causing a circular dependency error in g3.
This PR re-organize the code and "fixes" minor issues to remove this CD.
Please review the first commit only.
(You can check the 2nd but it's only updating generated files)