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

Provide an example usage of registerLocaleData() #2182

Open
salemdar opened this issue Jan 4, 2018 · 7 comments
Open

Provide an example usage of registerLocaleData() #2182

salemdar opened this issue Jan 4, 2018 · 7 comments

Comments

@salemdar
Copy link
Contributor

salemdar commented Jan 4, 2018

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[x] feature request
[ ] support request => Please do not submit support request here, instead see use [gitter](https://gitter.im/mgechev/angular2-seed) or [stackoverflow](https://stackoverflow.com/questions/tagged/angular2)

According to the documentation, registerLocaleData() method is needed to change the pipe formats.

Current i18n mechanism of angular-seed doesn't use registerLocaleData() method at all.

@maxmarkus
Copy link

maxmarkus commented Jan 23, 2018

I tried to add locales similar to the other packages, but didn't succeeded.

let additionalPackages: ExtendPackages[] = [
  {
    name: '@angular/common/locales/de',
    path: 'node_modules/@angular/common/locales/de.js'
  }

Which results in an error

TypeError: Unable to dynamically transpile ES module
A loader plugin needs to be configured via SystemJS.config({ transpiler: 'transpiler-module' }).

As it they are not recognized it seems.

@tobiaseisenschenk
Copy link
Contributor

tobiaseisenschenk commented Feb 16, 2018

In the AppModule
import { registerLocaleData } from '@angular/common';
import localeDe from '@angular/common/locales/de';

registerLocaleData(localeDe, 'de');

for JIT i also added
@NgModule({ { provide: LOCALE_ID, useValue: 'de' } })

And then you also need to add the npm dependency to your project.config
{ name: '@angular/common/locales/de', path: '${this.NPM_BASE}@angular/common/locales/de.js' }

With this configuration the aot build works for me, im happy to provide further details if needed.

@salemdar
Copy link
Contributor Author

Hey @tobiaseisenschenk, thanks for your input. But when I do that and run yarn start I receive the following error:

(index):65 TypeError: Unable to dynamically transpile ES module
   A loader plugin needs to be configured via `SystemJS.config({ transpiler: 'transpiler-module' })`.
    at transpile (http://localhost:5555/node_modules/systemjs/dist/system.src.js?1518778235730:3680:11)
    at http://localhost:5555/node_modules/systemjs/dist/system.src.js?1518778235730:3462:12
    at ZoneDelegate.invoke (http://localhost:5555/node_modules/zone.js/dist/zone.js?1518778235733:388:26)
    at Zone.run (http://localhost:5555/node_modules/zone.js/dist/zone.js?1518778235733:138:43)
    at http://localhost:5555/node_modules/zone.js/dist/zone.js?1518778235733:858:57
    at ZoneDelegate.invokeTask (http://localhost:5555/node_modules/zone.js/dist/zone.js?1518778235733:421:31)
    at Zone.runTask (http://localhost:5555/node_modules/zone.js/dist/zone.js?1518778235733:188:47)
    at drainMicroTaskQueue (http://localhost:5555/node_modules/zone.js/dist/zone.js?1518778235733:595:35)
    at <anonymous> Not expecting this error? Report it at https://github.com/mgechev/angular-seed/issues

@unnamed666
Copy link

i can't figure it out either, only solution that works for me is to copy locale.js to base app folder, change it to .ts and then import - but it's far from optimal :)

@salemdar
Copy link
Contributor Author

@mgechev Do you have any idea about this one?

@zkirill
Copy link

zkirill commented May 3, 2018

Solution by @tobiaseisenschenk worked for me for AOT.

For CLI this is the behavior:

The CLI imports the locale data for you when you use the parameter --locale with ng serve and ng build.

Can we add --locale parameter and mimic this behavor?

@govindmahecha
Copy link

govindmahecha commented May 28, 2018

install dependencies
npm i systemjs-plugin-babel

add following line in SYSTEM_CONFIG_DEV @ /tools/config/seed.config.js
map: {
'plugin-babel': 'path/to/systemjs-plugin-babel/plugin-babel.js',
'systemjs-babel-build': 'path/to/systemjs-plugin-babel/systemjs-babel-browser.js'
},
transpiler: 'plugin-babel'

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

6 participants