Caching issue, when dynamically loading locales #61692
Labels
area: i18n
Issues related to localization and internationalization
needs: clarification
This issue needs additional clarification from the reporter before the team can investigate.
Milestone
Uh oh!
There was an error while loading. Please reload this page.
Which @angular/* package(s) are the source of the bug?
common
Is this a regression?
No
Description
When loading locales dynamically and not using
registerLocaleData
which happens, if you load locales as script form a asset folder for example, there is an issue with locales that are cached in thelocale_data_api
. Those are not updated:angular/packages/core/src/i18n/locale_data_api.ts
Lines 103 to 112 in c11527f
when
getLocaleData
is called with a locale that isn't loaded yet, it will set the cachedLOCALE_DATA
for the specific locale, but this won't be updated the next timegetLocaleData
is called, if the locale is loaded by that time. so this will always mismatch and throw an error.registerLocaleData
on the other hand overwrites the Local inLOCALE_DATA
whenever called.I think the correct behavior would be to check not only if
normalizedLocale
isin LOCALE_DATA
but if it holds valid locale data and if not, try to reload the locale fromglobal
.Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run
ng version
)Anything else?
I can provide a PR if needed
The text was updated successfully, but these errors were encountered: