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

ng build --localize - TypeError: Cannot set property 'locale' of undefined #30

Open
plutosimple opened this issue May 8, 2020 · 1 comment

Comments

@plutosimple
Copy link

plutosimple commented May 8, 2020

Confusing error when building my app.

main-es2015.0fd75965dc41d73c1b29.js:24 TypeError: Cannot set property 'locale' of undefined
    at XMLHttpRequest.a.onload [as __zone_symbol__ON_PROPERTYload] (main-es2015.0fd75965dc41d73c1b29.js:24)
    at XMLHttpRequest.T (polyfills-es2015.d546a0e4758536877cfd.js:1)
    at a.invokeTask (polyfills-es2015.d546a0e4758536877cfd.js:1)
    at i.runTask (polyfills-es2015.d546a0e4758536877cfd.js:1)
    at c.invokeTask [as invoke] (polyfills-es2015.d546a0e4758536877cfd.js:1)
    at h (polyfills-es2015.d546a0e4758536877cfd.js:1)
    at XMLHttpRequest.p (polyfills-es2015.d546a0e4758536877cfd.js:1)

REPRO:

  1. ng build --localize
  2. http-serve the built bits

Correct me if I'm wrong, but isnt this is by design...? AOT build in angular won't have the library $localize library and really, there is no need to load this library.

I'd suggest a friendlier error message when this happens and an update to the core documentation to note not to include with localized builds.

Ex:

if (!environment.prodMode) {
     getTranslations('/assets/i18n/fr.json').then(
       (data: ParsedTranslationBundle) => {
         platformBrowserDynamic()
           .bootstrapModule(AppModule)
           .catch(err => console.error(err));
      );
} else {
...
}

@ocombe
Copy link
Collaborator

ocombe commented May 27, 2020

You might still need $localize for code translations, but if you're only using it in templates then yes, you might not need it, but then you don't really need Locl in this case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants