Content-Length: 251781 | pFad | http://github.com/angular/angular/issues/61692

43 Caching issue, when dynamically loading locales · Issue #61692 · angular/angular · GitHub
Skip to content

Caching issue, when dynamically loading locales #61692

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

Open
dersia opened this issue May 26, 2025 · 2 comments
Open

Caching issue, when dynamically loading locales #61692

dersia opened this issue May 26, 2025 · 2 comments
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

Comments

@dersia
Copy link

dersia commented May 26, 2025

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 the locale_data_api. Those are not updated:

export function getLocaleData(normalizedLocale: string): any {
if (!(normalizedLocale in LOCALE_DATA)) {
LOCALE_DATA[normalizedLocale] =
global.ng &&
global.ng.common &&
global.ng.common.locales &&
global.ng.common.locales[normalizedLocale];
}
return LOCALE_DATA[normalizedLocale];
}

when getLocaleData is called with a locale that isn't loaded yet, it will set the cached LOCALE_DATA for the specific locale, but this won't be updated the next time getLocaleData 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 in LOCALE_DATA whenever called.

I think the correct behavior would be to check not only if normalizedLocale is in LOCALE_DATA but if it holds valid locale data and if not, try to reload the locale from global.

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

NG0701

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 19.2.11
Node: 20.18.0
Package Manager: npm 10.8.2
OS: win32 x64

Angular: 19.2.10
... animations, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1902.11
@angular-devkit/build-angular   19.2.11
@angular-devkit/core            19.2.11
@angular-devkit/schematics      19.2.11
@angular/cdk                    19.2.15
@angular/cli                    19.2.11
@schematics/angular             19.2.11
rxjs                            7.8.2
typescript                      5.8.3
zone.js                         0.15.0

Anything else?

I can provide a PR if needed

@JeanMeche
Copy link
Member

I'm not sure what you're suggesting is the right soluation either.

Functions that rely on getLocaleData expect to get the locale data. You should be loading it before hitting that function.

@thePunderWoman thePunderWoman added the area: i18n Issues related to localization and internationalization label May 27, 2025
@ngbot ngbot bot added this to the needsTriage milestone May 27, 2025
@JeanMeche JeanMeche added the needs: clarification This issue needs additional clarification from the reporter before the team can investigate. label May 28, 2025
@JeanMeche
Copy link
Member

Could you please provide a mininal repro on how you would expect to use the feature, it'll help us understand your use case. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: i18n Issues related to localization and internationalization needs: clarification This issue needs additional clarification from the reporter before the team can investigate.
Projects
None yet
Development

No branches or pull requests

3 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/angular/angular/issues/61692

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy